日期:2014-05-17 浏览次数:20691 次
public void createRepairLog(String p_registNo, String p_verifylossNo) {
String details = "事故号:" + p_registNo + "定损单号:" + p_verifylossNo;
BufferedWriter out = null;
OutputStreamWriter osw = null;
FileOutputStream fos = null;
Date d = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
String exDate = sdf.format(d);
/* 文件名 */
File file = new File("test.txt"); //路径要怎么写?
try {
file.createNewFile();
fos = new FileOutputStream(file, true);
if(fos==null){
}else{
}
osw = new OutputStreamWriter(fos);
out = new BufferedWriter(osw);
out.write(exDate + System.getProperty("line.separator"));
// 将String写入到文件中
out.write(details);
out.flush();
} catch (Exception e1) {
e1.printStackTrace();
} finally {
try {
fos.close();
osw.close();
out.close();
} catch (IOException e1) {
e1.printStackTrace();
}
}
}