import java.io.*;
public class TestFileReader {
public static void main(String[] args) {
FileReader fr = null;
int c = 0;
try {
fr = new FileReader("d:java\TestFileReader.java");
int ln = 0;
while ((c = fr.read()) != -1) {
//char ch = (char) fr.read();
System.out.print((char)c);
//if (++ln >= 100) { System.out.println(); ln = 0;}
}
fr.close();
} catch (FileNotFoundException e) {
System.out.println("找不到指定文件");
} catch (IOException e) {
System.out.println("文件讀取錯誤");
}
}
}
有些情況下賦值了null就不會包變量未初始化了
http://zhidao.baidu.com/link?url=IPm8OXUs5QluOBQXD2PJ0vfO32pLb8U8CPkURSHWM8nUi71xMRd4ErOy7wiO0KgWMsYLFjxZvSLwQpnS8ZmivK