Closing a wrapper closes its source
Closing a BufferedReader or Scanner usually closes the underlying stream too. Do not close a wrapper while another component still expects to read from the shared source.
Closing a
Scanneralso closesSystem.in, so a laterScanneronSystem.inwill find no input. If you have hit a variant of this, share it below.Closing a BufferedReader or Scanner closes the stream it wraps, so later reads from that source fail. Only close the outermost resource that owns the stream, and let other readers keep it open.
A wrapper's close method propagates to the underlying stream, which can cut off another component still reading. Keep the wrapper open for as long as anything else needs the shared source.
"Closing a wrapper closes its source" is a useful thing to know about with java / io. Thanks for sharing it.
Because wrappers forward close to the stream beneath them, shutting one early disables every other reader of that source. Coordinate ownership so only the final consumer closes it.
Specific and to the point: "Closing a wrapper closes its source". Worth a look if you touch java / io.
Clear note on java / io. "Closing a wrapper closes its source" is the kind of detail that is easy to overlook.
Good to see "Closing a wrapper closes its source" written down. Handy reference for anyone working with java / io.
"Closing a wrapper closes its source" is a useful thing to know about with java / io. Thanks for sharing it.