package com.knock.io;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import org.junit.Test;
/**
* @date 160802am
* 测试怎么把东西写到文件
* */
public class KbOutput {
@Test
public void test(){
OutputStream os =null;
try {
os = new FileOutputStream("E:/test/a.txt",true);//os = new FileOutputStream("E:/test/a.txt");
String str = "i m shadow u r light\n";
byte[] arr = str.getBytes();
os.write(arr);
os.flush();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}finally{
try {
if(null!=os){
os.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
java.se.io.2输出流
最新推荐文章于 2024-06-04 17:41:05 发布