From OutputStream.flush()
docs.
Why does it state here in the doc that the flush method of OutputStream
does nothing after explaining that it actually does something? Very confusing.
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.
The Flush method is used when you need to send the contents of the Stream buffer to the associated underlying object. For example, a node or file represented by the URL that is the source of the Stream object. This will ensure that all changes made to the contents have been written.
The flush() method of PrintWriter Class in Java is used to flush the stream. By flushing the stream, it means to clear the stream of any element that may be or maybe not inside the stream. It neither accepts any parameter nor returns any value.
The flush() method of PrintStream Class in Java is used to flush the stream.
OutputStream
is an abstract class to be derived from. Subclasses will provide their own implementation if necessary. Otherwise the default behaviour is to do nothing.
e.g. see the code for ObjectOutputStream.flush()
OutputStream
is an abstract class.
The deriving instance has to override that, if it needs a flush.
For example the BufferedOutputStream
.
Streams that have no buffer may not need to override flush()
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With