Chinaunix首页 | 论坛 | 博客
  • 博客访问: 93423
  • 博文数量: 41
  • 博客积分: 1905
  • 博客等级: 上尉
  • 技术积分: 335
  • 用 户 组: 普通用户
  • 注册时间: 2009-07-10 20:07
文章分类

全部博文(41)

文章存档

2011年(1)

2010年(18)

2009年(22)

我的朋友

分类: Java

2009-07-19 14:46:06

java IO重定向
 
package aaa;
import java.io.*;
public class Redirecting
{
 public static void main(String[] args)throws IOException
 {
  BufferedInputStream in =new BufferedInputStream(new FileInputStream("D:/log.log"));
  PrintStream out = new PrintStream(new BufferedOutputStream(new FileOutputStream("test.out")));
  System.setIn(in);
  System.setOut(out);
  System.setErr(out);
  BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
  String s;
  while((s=br.readLine())!=null)
   System.out.println(s);
  out.close();
 }
}
阅读(628) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~