When do we need to flush an output stream?

When do we need to flush an output stream?

The stream data available in the buffer needs to be flushed out, when new data is to be written to that buffer. The flushed out stream outputs the bytes to another output stream. The contract of flush() method is to be flushed / written to their intended destination output stream immediately.

When do we need to flush an output stream?

If any bytes that are previously written and have been buffered by the implementation of the output stream then such bytes need to be immediately written to their intended destination. This is where flush needs to be used. It flushes this output stream and forces any buffered output bytes to be written out.

The use of flush() comes when any bytes previously written have been buffered by the implementation of the output stream. Such bytes should be immediately written to their expected destination.
Explain the purpose of garbage collection that the JVM uses
Garbage collection in Java identifies and discards the objects that are no longer needed by a program....
Explain how to read a line of input at a time
Input from the console is read from the System.in object and is then wrapped by an InputStreamReader which reads one character at a time......
How does Java handle integer overflows and underflows?
If a type exceeds a range of a type, it results in an overflow...
Post your comment