Best way to write String to file using java nio

后端 未结 5 1921
清歌不尽
清歌不尽 2021-01-30 12:49

I need to write(append) huge string to flat file using java nio. The encoding is ISO-8859-1.

Currently we are writing as shown below. Is there any better

5条回答
  •  不思量自难忘°
    2021-01-30 13:44

    This works for me:

    //Creating newBufferedWritter for writing to file
    BufferedWritter napiš = Files.newBufferedWriter(Paths.get(filePath));
                        napiš.write(what);
    //Don't forget for this (flush all what you write to String write):                     
                        napiš.flush();
    

提交回复
热议问题