/*
时间:2015年3月10日20:59:21
测试日志文件的简单实用
使用标准输入System.in
*/
import java.io.*;
import java.util.*;
public class TestPrintStream3 {
public static void main(String[] args) {
String s = null;
try{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
FileOutputStream fos = new FileOutputStream("D:/bak/loggin.txt", true);//true则追加
PrintStream ps = new PrintStream(fos);
while ((s = br.readLine()) != null) {
if (s.equalsIgnoreCase("exit"))
break;
System.out.println(s.toUpperCase());
System.out.println("------------------");
ps.println(s.toUpperCase());
ps.flush();
}
ps.println("=========" + new Date() +"==========");
ps.flush();
ps.close();
fos.close();
br.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
/*
FDFD
FDFD
FDSFADFS
=========Tue Mar 10 20:57:59 CST 2015==========
FHDJSFHJDHFJ
FDHJSFHJDF'DF
FDHJSFDHFJ
FHDJHFJS
=========Tue Mar 10 20:58:24 CST 2015==========
*/