Java 표준 I/O 리 셋

package io;

import java.io.*;
/*  I/O   
 *                ,                    。
 *            System.out     ,                 */
public class Redirecting {
    public static void main(String[] args)throws IOException{
    	PrintStream console=System.out;
    	BufferedInputStream in=new BufferedInputStream(new FileInputStream("D:\\NewJavaWorkspace\\18JavaIO  \\src\\io\\Redirecting.java"));
    	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();
    	System.setOut(console);
    }
}

좋은 웹페이지 즐겨찾기