public class ExceptionInfo
{
public static void main(String[] args)
{
try
{
int [] a = new int[2];
System.out.println(a[2]);
}catch(Exception e)
{
PrintStream ps =null;
try
{
ps = new PrintStream("D:/e.txt");
}catch(Exception ex )
{
ex.printStackTrace(ps);
}
Date d = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("YYYY-MM-dd HH:mm:ss");
String s = sdf.format(d);
ps.println(s);
e.printStackTrace(ps);
}
}
}
老师的这个程序为什么每次运行都会覆盖D:/e.txt这个原文件内容,怎么才能设置成不覆盖啊?