int data = new DataInputStream(new FileInputStream("aaa.txt")).readInt();

解决方案 »

  1.   

    private String readFile(String filePath, BufferedReader reader)
        throws FileNotFoundException, IOException {
            codeString = null;
            int i = 0;
            FileInputStream fis = new FileInputStream(filePath);
            if (reader == null)
            reader = new BufferedReader(new InputStreamReader(fis));
            String line = reader.readLine();
            while (line != null){
                line = reader.readLine();
            }
            return codeString;
        }这样就可以了,然后可以调用并返回读入的数据
    调用函数的时候记得try就行了
      

  2.   

    楼上的有少少笔误。        while (line != null){
                line = reader.readLine(); // codeString = reader.readLine();
            }
      

  3.   

    private String readFile(String filePath, BufferedReader reader)
        throws FileNotFoundException, IOException {
            codeString = null;
            int i = 0;
            FileInputStream fis = new FileInputStream(filePath);
            if (reader == null)
            reader = new BufferedReader(new InputStreamReader(fis));
            String line = reader.readLine();
            while (line != null){
                line = reader.readLine();
            }
            return codeString;
        }这样就可以了,然后可以调用并返回读入的数据
    调用函数的时候记得try就行了
      

  4.   

    int data = new DataInputStream(new FileInputStream("aaa.txt")).readInt();不是很方便吗,又不是读一行。
      

  5.   

    int data = new DataInputStream(new FileInputStream("aaa.txt")).readInt();
    //相当于
       FileInputStream fin = new FileInputStream("aaa.txt");
       DataInputStream din = new DataInputStream(fin);
       int data = din.readInt();