public void writeInt(int v)
              throws IOException
    
    Writes an int value, which is comprised of four bytes, to the output stream. The byte values to be written, in the order shown, are: 
 (byte)(0xff & (v >> 24))
 (byte)(0xff & (v >> 16))
 (byte)(0xff & (v >>    8))
 (byte)(0xff & v)

解决方案 »

  1.   

    to jianlin:
    把DataOutputStream改成OutputStreamWriter? 还是乱码!to OneNight:
    还是没明白什么意思。你是想说四个字节的值分别是你写的那样吗?
      

  2.   

    1. DataOutputStream 的 writeInt(),writeDouble() 等方法输出的内容不是字符型的,因此显示为乱码,但可以通过相应的readInt(),readDouble()等方法读出。上述方法输出的内容是给程序使用的,而不是给人来看的。如果要显示字符型数据,可以使用writeChar()方法。2. 一个字节表示的数的范围是-128~+127,采用二进制补码表示,最高位为符号位。