本文就关于IO资源的处理问题,提出三种方案。
close()放在try块中
close()放在finally块中
使用try-with-resource语句
close()放在try块中
more
//close() is in try clause
try {
PrintWriter out = new PrintWriter(
new BufferedWriter(
new FileWriter("out.txt", true)));
out.println("the text");
out.close();
} catch (IOException 继续阅读 »