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.
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.
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()
.
public abstract void write(int b)
Seems to be the only method of OutputStream
that is not implemented. All the others have default implementations (even if they do nothing). –
Guessrope The first part of the text is describing the general contract of flush
. Classes which extend OutputStream
are expected to adhere to this contract.
OutputStream
is an abstract class, but a default implementation of flush
is provided. As described, the implementation does nothing.
© 2022 - 2024 — McMap. All rights reserved.