package ioexample;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
public class TestFileReader {
public static void main(String[] args) {
int c=0;
FileReader fr=null;
try {
fr= new FileReader("F:\\test\\io\\TestFileReader.txt");
}
catch (FileNotFoundException e) {
System.out.println("找不到指定文件");
System.exit(-1);
}
try {
while((c=fr.read())!=-1){
System.out.println((char)c);
}
fr.close();
}
catch (IOException e) {
e.printStackTrace();
}
}
}
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
public class TestFileReader {
public static void main(String[] args) {
int c=0;
FileReader fr=null;
try {
fr= new FileReader("F:\\test\\io\\TestFileReader.txt");
}
catch (FileNotFoundException e) {
System.out.println("找不到指定文件");
System.exit(-1);
}
try {
while((c=fr.read())!=-1){
System.out.println((char)c);
}
fr.close();
}
catch (IOException e) {
e.printStackTrace();
}
}
}