java TestPrintStream

package org.lunzi.test.io;

import java.util.*;
import java.io.*;
public class TestPrintStream3 {
  public static void main(String[] args) {
    String s = null;
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    try {
      FileWriter fw = new FileWriter("e:\\org\\test.log", true); //Log4j
      PrintWriter log = new PrintWriter(fw);
      while ((s = br.readLine())!=null) {
        if(s.equalsIgnoreCase(
"exit"))
         break;
        System.out.println(s.toUpperCase());
        log.println(
"-----");
        log.println(s.toUpperCase());
        log.flush();
      }
      log.println(
"==="+new Date()+"===");
      log.flush();
      log.close();
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
}
lunzi   2008-11-08 21:54:30 评论:0   阅读:273   引用:0

发表评论>>

署名发表(评论可管理,不必输入下面的姓名)

姓名:

主题:

内容: 最少15个,最长1000个字符

验证码: (如不清楚,请刷新)

Copyright@2004-2010 powered by YuLog