1.

What is BufferedWriter? What are flush() and close() used for?

Answer»

BufferedWriter is a TEMPORARY data storage source. It's used to make a buffered character output stream with the default output buffer size.

To flush CHARACTERS from the buffered writer stream to a file, the flush() function of the BufferedWriter class in Java is employed. It ensures that all data items, including the last character, are WRITTEN to the file.

The close() function of the Java BufferedWriter class flushes the characters from the buffer stream and then closes it. Calling methods like write() and append() after the stream has been CLOSED will generate an ERROR.



Discussion

No Comment Found