写文件最佳组合
PrintWriter out = new PrintWriter(
new BufferedWriter(
new FileWriter(filename)))
PrintWriter 提供print系方法
BufferedWriter 提供缓冲,用以加速
FileWriter 用于写文件
java.io
Class FileWriter
java.lang.Object
|
+--java.io.Writer
|
+--java.io.OutputStreamWriter
|
+--java.io.FileWriter
public class FileWriter
Convenience 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.PrintWriter
public class PrintWriter
Print 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.