Buffered IO rudimentary question

J

jmw

If you have a reference to a buffered output stream, and you call
close(), will flush() automatically be called?
 
J

John W. Kennedy

jmw said:
If you have a reference to a buffered output stream, and you call
close(), will flush() automatically be called?

Yes. (This behavior is inherited from FilterOutputStream.)

What you /cannot/ assume is that program shutdown and or finalize() will
do this.
 
K

Knute Johnson

jmw said:
If you have a reference to a buffered output stream, and you call
close(), will flush() automatically be called?

Read the docs. BufferedOutputStream extends FilterOutputStream.

"close

public void close()
throws IOException

Closes this output stream and releases any system resources
associated with the stream.

The close method of FilterOutputStream calls its flush method, and
then calls the close method of its underlying output stream. "
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top