Difference between PrintWriter and FileWriter class

后端 未结 4 1638
灰色年华
灰色年华 2021-02-05 21:17
try{

    File file = new File(\"write.txt\");
    FileWriter writer = new FileWriter(file);

    PrintWriter printWriter = new PrintWriter(writer);
    printWriter.prin         


        
4条回答
  •  不思量自难忘°
    2021-02-05 21:50

    PrintWriter gives you some handy methods for formatting like println and printf. So if you need to write printed text - you can use it. FileWriter is more like "low-level" writer that gives you ability to write only strings and char arrays. Basically I don't think there is a big difference what you choose.

提交回复
热议问题