读书人

把字符串写下本地文件保存 java 源码

发布时间: 2012-12-28 10:29:05 作者: rapoo

把字符串写入本地文件保存 java 源码
public void FileOutputStream(String str) throws Exception{

// File txt=new File("D:\\Documents and Settings\\bizOrdeId.txt");
//if(!txt.exists()){
//txt.createNewFile();
//}
//byte bytes[]=new byte[512];
//bytes=str.getBytes(); //
//int b=str.length(); //改
//FileOutputStream fos=new FileOutputStream(txt);
//fos.write(bytes,0,b);
//fos.close();


String path="D://Documents and Settings//bizOrdeId.txt";
try {
FileWriter fw=new FileWriter(path,true);
BufferedWriter bw=new BufferedWriter(fw);
bw.newLine();
bw.write(str);
bw.close();
fw.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

读书人网 >编程

热点推荐