26.标准输入输出操作

标准输入/输出流
System.out.println("begin...");
int data = System.in.read();
System.out.println(data);
System.out.println("begin...");
重定向标准输入/输出流
System.setIn(new FileInputStream("file/123.txt"));
                
System.setOut(new PrintStream(new FileOutputStream("file/ccc.txt")));
                
int len = -1;
byte[] buffer = new byte[1024];
while((len = System.in.read(buffer)) != -1){
                    
    System.out.println(new String(buffer,0,len));
                    
}

你可能感兴趣的:(26.标准输入输出操作)