示例1.4 字节流输出

来源:互联网 发布:mac能玩守望先锋吗 编辑:程序博客网 时间:2024/05/01 09:46
package com.mstf.scme.test7;


import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;


public class Foss {
public static void main(String[] args) {
File file=new File("E://999.txt");
FileOutputStream fos=null;
try {
fos=new FileOutputStream(file);
String data="Hello Mstanford";
byte[] byt=data.getBytes();
fos.write(byt);
} catch (FileNotFoundException e) {
// TODO: handle exception
e.printStackTrace();
}catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}finally{
if (fos!=null) {
try {
fos.close();
} catch (Exception e2) {
// TODO: handle exception
e2.printStackTrace();
}
}
}
}
}
0 0
原创粉丝点击