DataInputStream/DataOutputStream are used for binary stream, not ascii stream.
a simple sample how to use them:
try{
   DataOutputStream out=
         new DataOutputStream(new FileOutputStream("data.txt"));
  out.writeByte(1);
  out.writeInt(2);
  out.flush();
  out.close();
}catch(IOException e){
  e.printStackTrace();
}try{
   DataInputStream dis = new DataInputStream(
                   new FileInputStream("data.txt"));
   int a=dis.readByte();
   System.out.println(a);
   a=dis.readInt();
   System.out.println(a);
   dis.close();
}catch(IOException e){
   e.printStackTrace();
}

解决方案 »

  1.   

    public int readInt() throws IOException
    Reads 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))
     For your example:Input 1:
    You will get ch1 =49,ch2 =13,ch3=10
    after you Input 2:
    you get ch4 =50
    then:
    ((ch1 << 24) + (ch2 << 16) + (ch3 << 8) + (ch4 << 0)) = 822938162
      

  2.   

    thanks guys. 
    Thanks for your advice.