您的位置:首页 > 其它

练习 2017-08-15 标准输入输出流。扫描器。

2017-08-15 19:58 253 查看
package standardIO;

import java.io.File;

import java.io.FileInputStream;

import java.io.PrintStream;

import java.util.Scanner;

//标准输出输出流  和扫描器

public class StandardIODemo {
public static void main(String[] args) throws Exception {
//标准输出重定向
System.setOut(new PrintStream(new File("process/system.txt")));
//标准输入重定向
System.setIn(new FileInputStream("process/WriterDemo.txt"));
System.out.println("-------begin----");
Scanner input =new Scanner(System.in);

while(input.hasNextLine()){
System.out.println(input.nextLine());
}
input.close();
System.out.println("-------end----");
}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: