When you use the
try-with-resources
statement correctly, then you will never have to close streams explicitly.
(Indeed, that's the reason try-with-resources was added in the first place.)

However, you may see still see code that either doesn't use a modern JDK, or
fails to take advantage of try-with-resources.

JDK < 7

Streams represent resources which you must always clean up explicitly,
by calling the close method.

Some java.io classes (apparently just the output classes)
include a flush method. When a close method
is called on a such a class, it automatically performs a flush.
There is no need to explicitly call
flush before calling close.

One stream can be chained to another by passing it to the constructor of
some second stream. When this second stream is closed, then it automatically
closes the original underlying stream as well.

If multiple streams are chained together, then closing the one which
was the last to be constructed, and is thus at the highest level of abstraction,
will automatically close all the underlying streams. So, one only has to
call
close on one stream in order to close (and flush, if applicable)
an entire series of related streams.