import java.io.*;
public class TestIo {
public static void main(String[] args) {
File src = new File("a.txt");//创建源
FileInputStream fis = null;//选择流
try {//读取操作
fis = new FileInputStream(src);
int temp;
while ((temp = fis.read()) != -1) {//读不到内容返回-1
System.out.println((char)temp);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
}catch (IOException e) {
e.printStackTrace();
}
finally {//释放资源
try {
if (fis != null) {//如果不是空指针释放资源
fis.close();
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}