62,612
社区成员
发帖
与我相关
我的任务
分享
package com.cn.shijiu;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintStream;
import java.text.SimpleDateFormat;
import java.util.Date;
public class Test1
{
public static void main(String args[]) throws IOException
{
try
{
int[] a = new int[2];
System.out.println(a[3]);
} catch (Exception e)
{
try
{
FileWriter fw = new FileWriter("d:\\log.txt");
Date d = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String s = sdf.format(d);
fw.write(s);
fw.flush();
e.printStackTrace(new PrintStream("d:\\log.txt"));
} catch (FileNotFoundException e1)
{
e1.printStackTrace();
}
}
}
}
import java.io.*;
import java.text.SimpleDateFormat;
import java.util.Date;
public class Test1
{
public static void main(String args[]) throws IOException
{
try
{
int[] a = new int[2];
System.out.println(a[3]);
} catch (Exception e)
{
try
{
FileWriter fw = new FileWriter("d:\\log.txt",true);
Date d = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String s = sdf.format(d);
fw.write(s);
fw.write("\r\n");
fw.flush();
e.printStackTrace(new PrintWriter(fw));
fw.close();
} catch (FileNotFoundException e1)
{
e1.printStackTrace();
}
}
}
}