FileOutputStream.close is really slow when writing large file

后端 未结 2 1643
伪装坚强ぢ
伪装坚强ぢ 2020-12-04 02:04

I have a method which receives a file over a TCP socket using this code:

FileOutputStream fileStream = new FileOutputStream(filename.getName());
while (total         


        
2条回答
  •  情歌与酒
    2020-12-04 02:47

    I saw the same with using filestream. What I found there was if you open the file as readwrite, it cached everything and didn't write until you close or dispose. Flush didn't write. However if your writes extend the size of the file it would autoflush.

    Opening as just write autoflushed on each write.

提交回复
热议问题