一、字符输入流
1、使用步骤
1、创建FileReader对象,构造方法中绑定要读取的数据源
2、使用FileReader对象方法reader读取文件
3、释放资源
2、代码1
public class Demo09 {
public static void main(String[] args) throws IOException {
FileReader fr = new FileReader("E:\\D.txt");
int len = 0;
//一次读取单个字符
while((len=fr.read())!=-1){
System.out.println((char) len);
}
}
}
结果:
3、代码2
public class Demo10 {
public static void main(String[] args) throws IOException {
FileReader fe = new FileReader("E:\\D.txt");