Bufferedwriter works, but file empty?

前端 未结 4 702
忘掉有多难
忘掉有多难 2020-12-11 08:58

I have the following code:

CSVmaker(LinkedList data) {
    String [] myLines = makeStrings(data);
  //  for (int k = 0; k

        
4条回答
  •  旧巷少年郎
    2020-12-11 09:42

    Though the question is answered . I would like to add how buffer works.

    whenever you try to write to a file using buffer,whatever you write gets added to the buffer. When the buffer is full the contents are written to the file . This way we are reducing the number of hits to the hard-drive hence improving the efficency.

    If we want to forcefully write to a file without the buffer getting full , we use flush() method.

提交回复
热议问题