IO.Util中的log(日志)

来源:互联网 发布:linux关闭端口 编辑:程序博客网 时间:2024/06/06 20:22
import java.util.*;import java.io.*;public class TestPrintStream2log {public static void main(String[] args) {String str = null;BufferedReader br = new BufferedReader(new InputStreamReader(System.in));try{FileWriter fw = new FileWriter("E:\\sync\\Java\\TestPrintStream2log\\filelog.log", true);PrintWriter log = new PrintWriter(fw);while((str = br.readLine()) != null){if(str.equalsIgnoreCase("exit"))break;System.out.println(str.toUpperCase());System.out.println("------------");log.println(str.toUpperCase());log.flush();}log.println("---" + new Date() + "---");log.flush();log.close();}catch(IOException ioe){ioe.printStackTrace();}}}

0 0