wwangl is right.
The object fIn must be initiated before you can use it.

解决方案 »

  1.   

    怎么改阿
    fIn=new FileInputStream(fileName);
    不是吗?
      

  2.   

    我改了一下,可以运行了,
    不过这里,你可以随意建立一个text.txt的文件,
    在你面你可以输入字符,为什么不能正确显示阿?import java.io.*;public class java31{
    public static void  main(String [] args){
    String fileName="text.txt";
    byte outString[]=new byte[10];
    String outToScreen=new String();

    FileInputStream fileIn;
    try{
    fileIn=new FileInputStream(fileName);
    if(fileIn.read(outString,0,outString.length)!=-1)
    outToScreen=outString.toString();
    System.out.println(outToScreen);
    }
    catch(FileNotFoundException e)
    {
    System.out.println("File"+fileName+"Not Found");
    System.exit(-2);
    }
    catch(IOException e)
    {
    System.out.println("Error"+e);
    System.exit(-4);
    }
    }
    }
      

  3.   

    Here:
    import java.io.*;public class test{
      public static void  main(String [] args){
        String fileName="text.txt";
        byte outString[]=new byte[10];
        String outToScreen=new String();    FileInputStream fileIn;
        try{
          fileIn=new FileInputStream(fileName);
          while(fileIn.read(outString,0,outString.length)!=-1){
            outToScreen=new String(outString);
            System.out.println(outToScreen);
           }
        }catch(FileNotFoundException e){
          System.out.println("File"+fileName+"Not Found");
          System.exit(-2);
        }catch(IOException e){
          System.out.println("Error"+e);
          System.exit(-4);
        }
      }