java.io.PrintWriter和java.io.BufferedWriter之间的区别?
2022-08-31 10:09:10
请仔细阅读以下代码:
// A.class
File file = new File("blah.txt");
FileWriter fileWriter = new FileWriter(file);
PrintWriter printWriter = new PrintWriter(fileWriter);
// B.class
File file = new File("blah.txt");
FileWriter fileWriter = new FileWriter(file);
BufferedWriter bWriter = new BufferedWriter(fileWriter);
这两种方法有什么区别?
我们什么时候应该使用PrintWriter而不是BufferedWriter?