Difference between java.io.PrintWriter and java.io.BufferedWriter?

后端 未结 8 1461
南笙
南笙 2020-12-02 06:04

Please look through code below:

// A.class
File file = new File(\"blah.txt\");
FileWriter fileWriter = new FileWriter(file);
PrintWriter printWriter = new P         


        
8条回答
  •  心在旅途
    2020-12-02 06:52

    I think that the reason behind using PrintWriter is already mentioned above but one of the important reason is you an pass a file object directly to the PrintWriter constructor which makes it easy to use it.

    File file=new File(“newfile.txt”);
    PrintWriter pw=new PrintWriter(file);
    

提交回复
热议问题