package file;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
public class TestReader {
public static void main(String[] args) throws IOException {
String srcFilePath = "/Users/hike/Desktop/java/JavaSE/write.txt";
FileReader reader = new FileReader(srcFilePath);
// 一个字符一个字符的读取
// int ch;
// while((ch = reader.read()) != -1){
// char text = (char)ch;
// System.out.print(text);
// }
char[] chars = new char[4];
int len;
StringBuilder sb = new StringBuilder();
while ((len = reader.read(chars)) != -1){
String text = new String(chars, 0, len);
sb.append(text);
}
System.out.println(sb.toString());
reader.close();
}
}