package IO;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
public class FileoutputstreamTest {
FileOutputStream fos=null;
String name ="C:\\\\\\\\Users\\\\\\\\Administrator\\\\\\\\Desktop\\\\\\\\ZR.txt";
try {
fos=new FileOutputStream(name);
String str="qwer";
//将字符串的内容(qwer)写到name的文本文档里
try {
fos.write(str.getBytes());
} catch (IOException e) {
e.printStackTrace();
}
} catch (FileNotFoundException e) {
e.printStackTrace();
}finally{
try{
fos.flush();
}catch (IOException e) {
e.printStackTrace();
}
try{
fos.close();
}catch (IOException e) {
e.printStackTrace();
}
}
}
}