首页 > 编程语言 > 详细

java中将异常写入到txt文本

时间:2015-11-25 10:09:55      阅读:299      评论:0      收藏:0      [点我收藏+]

 

代码如下:

try{
	******
} catch (Exception ex) {
				  try {
					  File file = new File("e:/log.txt");

					  PrintWriter writer = null;
					  FileWriter fileWrite = new FileWriter(String.valueOf(file), true);
					  writer = new PrintWriter(fileWrite);
					  writer.append(System.getProperty("line.separator") + new SimpleDateFormat("yyyy-MM-dd:HH:mm:ss").format(new Date()));
					  writer.append(System.getProperty("line.separator"));
					  writer.append("*************************" + ex.toString() + "*************************");
					  writer.append(System.getProperty("line.separator"));
					  ex.printStackTrace(writer);
					  writer.flush();
					  writer.close();
				  } catch (IOException e) {
					  e.printStackTrace();
				  }
}

java中将异常写入到txt文本

原文:http://www.cnblogs.com/sjshare/p/4993703.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!