类图及构造方法
常用方法
int read() 读取单个字符, 返回字符的ASCII码值
int read(char[] ) 读取字符到指定的字符数组 , 返回字符数组末尾字符的序号
方法举例
char[] ch = new char[8];
FileReader fileReader = null;
String s = "f:\\world.txt";
int a =0;
try {
fileReader = new FileReader(s);
// 读取单个字符
// while((a = fileReader.read()) != -1) {
// System.out.print((char)a);
// }
while ((a = fileReader.read (ch))!=-1) {
System.out.print(new String(ch,0,a));
}
} catch (IOException e) {
throw new RuntimeException(e);
}