closing nested streams [duplicate]
问题 This question already has answers here : Closed 8 years ago . Possible Duplicate: Best way to close nested streams in Java? How we close nested streams? Closing all of them? If yes what is the order? FileOutputStream out = new FileOutputStream("data.txt", true); PrintWriter pout = new PrintWriter(out); /* do some I/O */ pout.close(); out.close(); or closing the the out most stream will close all of them. pout.close(); // Is this enough? 回答1: When closing chained streams, you only need to