package com.xiangshuai;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintStream;
/**
* @author lqx
* 防止程序奔溃,并将错误信息打印到硬盘文件
* */
public class forPrintLog {
public static void main(String[] args) {
PrintStream printStream=null;
try {
printStream = new PrintStream(new File("E:/log.txt"));
} catch (FileNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
String[] filePathsString={"E:/log.txt","E:/log1.txt","E:/log2.txt","E:/log3.txt"};
for (int i = 0; i < filePathsString.length; i++) {
try {
System.out.println(1/0);
} catch (Exception e) {
e.printStackTrace(printStream);
}
}
printStream.close();
}
}