zoukankan      html  css  js  c++  java
  • Java I/O学习 标准的I/O重定向

    public class Test{
    
    	/*
    	 * 标准的I/O重定向
    	 * System.setIn(InputStream)
    	 * System.setOut(PrintStream)
    	 * System.setErr(PrintStream)
    	 */
    	public static void main(String[] args) throws IOException {
    		PrintStream console = System.out;
    		BufferedInputStream in = new BufferedInputStream(new FileInputStream("/home/estar/Test/a.java"));
    		PrintStream out = new PrintStream("and.out");
    		
    		System.setIn(in);
    		System.setOut(out);
    		System.setErr(out);
    		
    		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    		String s = null;
    		while ((s = br.readLine()) != null) {
    			System.out.println(s);
    		}
    		out.close();
    		System.setOut(console);
    		
    	}
    }
    

      

  • 相关阅读:
    Python(多进程multiprocessing模块)
    Python(队列)
    Unique Paths
    Unique Paths
    Jump Game II
    Jump Game
    Path Sum II
    Path Sum
    Remove Element
    Implement strStr()
  • 原文地址:https://www.cnblogs.com/E-star/p/3443331.html
Copyright © 2011-2022 走看看