InputStream is = null;
OutputStream os = null;
try {
} catch (IOException e) {
} finally {
try {
if (os != null) {
os.close();
}
if (is != null) {
is.close();
}
} catch (IOException e2) {
}
}
try (
InputStream is = new FileInputStream("...");
OutputStream os = new FileOutputStream("...");
) {
} catch (IOException e) {
}
注: try()里每个声明的变量类型都必须是Closeable的子类。