package 练习;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
public class FileReaderDemo01 {
public static void main(String[] args) {
File file=new File("F:\\java92\\src\\练习\\world");
FileReader fr=null;
try {
fr=new FileReader(file);
char[] ch=new char[2];
int len;
while (( len=fr.read(ch))!=-1)
{
String str=new String(ch,0,len);
System.out.print(str);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
finally {
try {
fr.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
转载请注明原文地址:https://blackberry.8miu.com/read-18357.html