Does flush method for OutputStream do nothing?

From OutputStream.flush() docs.

Why does the document state that the flush OutputStream method OutputStream nothing after explaining that it really does something? Very confusing.

+8
java io outputstream
source share
3 answers

OutputStream is an abstract class that must be received. If necessary, subclasses will provide their own implementation. Otherwise, the default behavior is to do nothing.

eg. see code ObjectOutputStream.flush ()

+10
source share

OutputStream is an abstract class. An output instance should override this if it needs a flash. For example, BufferedOutputStream .
Threads that do not have a buffer may not need to override flush() .

+2
source share

The first part of the text describes the general flush contract. Classes that extend OutputStream are expected to adhere to this contract.

OutputStream is an abstract class, but a default flush implementation is provided. As described, the implementation does nothing.

0
source share

All Articles