import java.io.*;
public class TestInputStream
{
public static void main(String[] args)
{
FileInputStream in = null;
int b = 0;
int num = 0;
try{
in = new FileInputStream("F:/java/HelloWorld.txt");

}catch(FileNotFoundException e){
System.out.println("文件不存在");
//System.exit(-1);我把这里注释掉,为什么回报一个空指针的错误呀,他的运行原理是什么System.(-1)?
} try{
while((b=in.read()) != -1){
System.out.print((char)b);
//System.exit(-1);


num++;


}
in.close();
System.out.println();
System.out.println("读取字节的个数是:"+num);

}catch(IOException ee){
System.out.println("错误");
System.exit(-1);

}
}
}输出结果:F:\java\java2>java TestInputStream
文件不存在
Exception in thread "main" java.lang.NullPointerException
        at TestInputStream.main(TestInputStream.java:18)