0
votes

I have gone through the javadoc but I could't find anything.Does it buffer data internally? If yes, since there is no close/flush operation, how does it make sure all data has been written. If it does not buffer, Does it go to disk everytime call is made?

http://commons.apache.org/proper/commons-io/apidocs/org/apache/commons/io/FileUtils.html#write(java.io.File, java.lang.CharSequence, java.nio.charset.Charset, boolean)

I looked at source code here, http://grepcode.com/file/repo1.maven.org/maven2/commons-io/commons-io/2.4/org/apache/commons/io/FileUtils.java#FileUtils.openOutputStream%28java.io.File%2Cboolean%29 and it does not seem to do any buffering. It opens a stream every time.

1
Sure it has a close/flush operation; it just does it itself, rather than making you do it.Louis Wasserman

1 Answers

5
votes

From looking at the source, a new stream is created, the data is written out, and then the stream is closed.

Here's the link to the source I used to determine this. Eventually writeStringToFile is called when you call write.

This makes sense as its a static method which returns nothing.

So, it doesn't buffer data internally. Every time you call write data will be written to the file.