difference between flush and close function in case of filewriter in java

前端 未结 5 963
傲寒
傲寒 2020-12-04 11:56

I need to know what is exact difference between flush and close function in Java?

And When the data is dumped into a file during writing of file?

Please prov

5条回答
  •  失恋的感觉
    2020-12-04 12:46

    flush() :To flush output stream, use void flush() method of DataOutputStream class. This method internally calls flush() method of underlying OutputStream class which forces any buffered output bytes to be written in the stream.

    close() :It generally close the Stream,connection,socket.

    See flush and close example

提交回复
热议问题