import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileDescriptor;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;
public class SystemDemo01 {
public static void main(String[] args) throws FileNotFoundException {
//控制台到文件
//重定向
System.setOut(new PrintStream(new BufferedOutputStream(
new FileOutputStream("d:/test/print.txt")),true));
//加一个true相当于flush
System.out.println("bbb");//控制台到文件
//文件回控制台
System.setOut(new PrintStream(new BufferedOutputStream(
new FileOutputStream(FileDescriptor.out)),true));
System.out.println("Hello,World!");
}
//出入流
public static void test2() throws FileNotFoundException {
InputStream is =System.in;
is =new BufferedInputStream(new FileInputStream(new File("D:/test/print.txt")));
Scanner sc =new Scanner(is);
System.out.println(sc.nextLine());
}
//输出
public static void test1() {
System.out.println("hello");
System.err.println("错误信息");
}
}