bufferedwriter stops in the middle of writing

前端 未结 4 710
长情又很酷
长情又很酷 2021-01-18 02:39

For some reason this code results in a truncated text.txt file. It should (according to me) write out 1000 results, but the output file has various amounts of lines (dependi

4条回答
  •  爱一瞬间的悲伤
    2021-01-18 03:17

    Once you open io (Reader, Writter or BufferR/W, ...), you have to close it later to close that stream and release the resource. Incase your code has nested stream (File, FileReader, BufferedReader) or (Writer1, Writer2), you have to close it separately order right after(BufferedReader, FileReader, File) or (Writer1.close() before using Writer2)

提交回复
热议问题