/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package getandset; import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.util.Date; import javax.swing.JOptionPane; /** * * @author Administrator */ public class AddLog { public static void addlog(String error)//将错误信息写入日志 { FileWriter fw=null; BufferedWriter bw=null; File logFile=null; String containt=(new Date()).toString()+"\t\t"+error; try { logFile = new File("datalog.zhoujian"); if (!logFile.exists()) { logFile.createNewFile();//如果该日志文件不存在,则新建一个 } fw=new FileWriter(logFile,true);//以追加的模式操作文件 bw=new BufferedWriter(fw); bw.newLine(); bw.newLine(); bw.write(containt); bw.close(); fw.close(); } catch (IOException ex) { JOptionPane.showMessageDialog(null,"写入日志文件出错!","严重警告",JOptionPane.ERROR_MESSAGE); }finally{ } } }


siximu912 LV10
2023年7月14日
nurmamat001 LV2
2022年11月1日
lingqianjue LV3
2022年4月27日
Hachi6 LV13
2022年1月31日
空心菜4 LV9
2022年1月12日
占山为王7064 LV7
2021年12月31日
knklan LV8
2021年12月22日
BruceQ LV14
2021年12月8日
yangsi1025yss LV11
2021年11月29日
xiaokeimi01 LV15
2021年6月21日