public class Demo08 {
public static void main(String[] args){
System.out.println("helloworld");
PrintStream pt=System.out;
pt.println("Jvaa......");
try {
//通常用这种方法记录日志
//需求:记录日志,m1的方法开始执行的时间和结束的时间。记录到Log文件中
//setOut方法改变输入的方向。之后的System.out.println();都会改变
System.setOut(new PrintStream(new FileOutputStream("log")));
System.out.print("haha");
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss SSS");
System.out.println(sdf.format(new Date()));
m1();
System.out.println(sdf.format(new Date()));
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
private static void m1() {
System.out.println("m1 method execute!!!!");
}
}