package com.czie.iot1913.lps01.IO.ioTest.OutputStream;
import java.io.FileOutputStream;
import java.io.IOException;
/**
* @author 1944900433@qq.com
* @date 2022-03-22 22:34
*/
public class FileOutPutStreamDemo04 {
public static void main(String[] args) {
// try {
// FileOutputStream fos = new FileOutputStream("myList\\fos02.txt");
// fos.write("hello".getBytes());
// fos.close();
// }catch (Exception e){
// e.printStackTrace();
// }
//加入finally来实现释放资源
FileOutputStream fos = null;
try {
//fos = new FileOutputStream("Z:\\myList\\fos02.txt");
//FileNotFoundException OutputStream
fos = new FileOutputStream("myList\\fos02.txt");
fos.write("hello".getBytes());
} catch (Exception e) {
e.printStackTrace();
} finally {
if (fos != null) {
try {
fos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}