1.JDK7的关流方式
OutputStream out = null;
try {
out = new FileOutputStream("");
// ...操作流代码
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (out != null) {
out.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
2.JDK8的关流方式
try (OutputStream out = new FileOutputStream("")){
// ...操作流代码
} catch (Exception e) {
throw e;
}