Back

Explore Courses Blog Tutorials Interview Questions

Explore Tech Questions and Answers

Welcome to Intellipaat Community. Get your technical queries answered by top developers!

0 votes
2 views
by (1.5k points)
I was asked this question in an interview, can someone tell me the use of flush() in Java streams?

2 Answers

0 votes
by (7.2k points)

The flush() method of OutputStream class is used to flush the content of the buffer to the output stream. A buffer is a portion in memory that is used to store a stream of data(characters). That data sometimes will only get sent to an output device, when the buffer is full.

0 votes
by (1.4k points)

The java.io.Writer.flush() method flushes the stream 

The Java.io.Writer.flush() method flushes the stream. If the stream has saved any characters from the different write() methods in the buffer, write them to their intended destination instantly. 

Declaration: 

public abstract void flush() 

Related questions

0 votes
1 answer
0 votes
1 answer
asked Feb 17, 2021 in Java by Harsh (1.5k points)
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Browse Categories

...