练习 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----");
}
}
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----");
}
}
相关文章推荐
- IO操作 改变标准输入输出流和转换流练习
- 08_I/O输入输出流、文件重定向、格式控制、标准输入输出、 串流类、 文件操作、多线程
- Day22 --序列流 内存输出流 随机访问流 对象操作流 数据输入输出流 打印流 标准输入输出流 Properties
- 黑马程序员__字符流_序列流_内存流_对象操作流_打印流_标准输出流_数据输入输出流及Properties
- 改变标准输入输出流
- c++ 标准输入输出流基础
- 22 API-IO流(登陆注册IO版案例,数据操作流,内存操作流,打印流,标准输入输出流,:随机访问流,合并流,序列化流),Properties,NIO)
- 七、输入/输出流--IOStreamm基本类和标准IOStream对象--头文件和标准操纵符
- C++ 标准输入输出流、作用域运算符、注释:
- C++ IO流:标准输入输出流的重载
- 利用管道重定向标准输入输出流
- 标准输入输出流
- Java IO流->处理流->标准输入输出流:System.in&System.out
- java语言基础(85)——标准输入输出流 和 随机访问流
- java的标准输入/输出流
- 学习练习 java 输入输出流练习2
- C++提高 10(标准输入,输出流,文件io流)
- Java基础-22总结登录注册IO版,数据操作流,内存操作流,打印流,标准输入输出流,转换流,随机访问流,合并流,序列化流,Properties
- IO流之标准输入输出流
- 缓冲流,转换流,标准输入输出流