public class TestIO2 {
public static void main(String[] args) {
test1();
}
/*
* 不往上面throws,利用try/catch
*/
public static void test1() {
FileOutputStream fos = null;
try {
fos = new FileOutputStream("D:\\test2222.txt");
fos.write("haha".getBytes());
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
fos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}