www.javaalmanac.com
by the way:使用IOStream要做到read和write的顺序是一样的

解决方案 »

  1.   

    从终端读出来的是String,当然不能用readInt了
    你可以用String s=  in.readLine();
    然后int v = Integer.parseInt(s);
      

  2.   

    public int readInt()
                throws IOExceptionReads 
    four input bytes and returns an int value. Let a be the first byte read, b be the second byte, c be the third byte, and d be the fourth byte. The value returned is:  
     (((a & 0xff) << 24) | ((b & 0xff) << 16) |
      ((c & 0xff) << 8) | (d & 0xff))
     This method is suitable for reading bytes written by the writeInt method of interface DataOutput.
      

  3.   

    DataInputStream是一个二进制流,不能用于从中端读入数据