IO流:缓存流
package com.xuedao.main;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
/**
* 缓存流
* 字符的缓存流:BufferedReader
* @author 阿超
*
* 打印流:格式化输出/只有输出没有输入
* PrintWriter
*/
public class File04 {
public static void main(String[] args) throws IOException {
// File f = new File("D:/QQ文件/a.txt");
// BufferedReader in = new BufferedReader(new FileReader(f));
// int i = 0;
// while(true) {
// //readLine()先将数据请入到缓存区,再将数据转化为String类型,再清空缓存区
// String str = in.readLine();
// if(str == null) {
// break;
// }
// System.out.println(str + i++);
// }
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
while(true) {
String str = in.readLine();
System.out.println("echo:"+str);
if(str.equals("exit")) {
return;
}
}
}
}