java.io
Class FileWriter
java.lang.Object
|
+--java.io.Writer
|
+--java.io.OutputStreamWriter
|
+--java.io.FileWriterpublic class FileWriterConvenience class for writing character files. The constructors of this class assume that the default character encoding and the default byte-buffer size are acceptable. To specify these values yourself, construct an OutputStreamWriter on a FileOutputStream. java.io
Class PrintWriter
java.lang.Object
|
+--java.io.Writer
|
+--java.io.PrintWriterpublic class PrintWriterPrint formatted representations of objects to a text-output stream. This class implements all of the print methods found in PrintStream. It does not contain methods for writing raw bytes, for which a program should use unencoded byte streams.
写文件用前者比较合适吧.
Class FileWriter
java.lang.Object
|
+--java.io.Writer
|
+--java.io.OutputStreamWriter
|
+--java.io.FileWriterpublic class FileWriterConvenience class for writing character files. The constructors of this class assume that the default character encoding and the default byte-buffer size are acceptable. To specify these values yourself, construct an OutputStreamWriter on a FileOutputStream. java.io
Class PrintWriter
java.lang.Object
|
+--java.io.Writer
|
+--java.io.PrintWriterpublic class PrintWriterPrint formatted representations of objects to a text-output stream. This class implements all of the print methods found in PrintStream. It does not contain methods for writing raw bytes, for which a program should use unencoded byte streams.
写文件用前者比较合适吧.
PrintWriter out = new PrintWriter(
new BufferedWriter(
new FileWriter(filename)))
PrintWriter 提供print系方法
BufferedWriter 提供缓冲,用以加速
FileWriter 用于写文件