可能重复:
在 Java 中关闭嵌套流的最佳方法?
我们如何关闭嵌套流?全部关闭?如果是,顺序是什么?
FileOutputStream out = new FileOutputStream("data.txt", true);
PrintWriter pout = new PrintWriter(out);
/* do some I/O */
pout.close();
out.close();
或关闭最外面的流将关闭所有这些。
pout.close(); // Is this enough?