zoukankan      html  css  js  c++  java
  • java中将异常写入到txt文本

    代码如下:

    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();
    				  }
    }
  • 相关阅读:
    gnuplot
    charles证书安装
    jenkins 配置ssh
    jenkins 配置slave
    centos 安装jenkins
    mac的一些命令
    docker 常用命令
    GO vim环境
    go vendor目录
    protobuf
  • 原文地址:https://www.cnblogs.com/sjshare/p/4993703.html
Copyright © 2011-2022 走看看