你用BufferedInputStream完全多余,你应该在每个环节都用字节流。用PrintStream流就更不对了。看看这个说明,你就知道了,你把字节流变成了字符流。
在JAVA中字节和字符不是一回事,这个不象cA PrintStream adds functionality to another output stream, namely the ability to print representations of various data values conveniently. Two other features are provided as well. Unlike other output streams, a PrintStream never throws an IOException; instead, exceptional situations merely set an internal flag that can be tested via the checkError method. Optionally, a PrintStream can be created so as to flush automatically; this means that the flush method is automatically invoked after a byte array is written, one of the println methods is invoked, or a newline character or byte ('\n') is written. All characters printed by a PrintStream are converted into bytes using the platform's default character encoding. The PrintWriter class should be used in situations that require writing characters rather than bytes. 
public void write(byte[] buf,
                  int off,
                  int len)Write len bytes from the specified byte array starting at offset off to this stream. If automatic flushing is enabled then the flush method will be invoked. 
Note that the bytes will be written as given; to write characters that will be translated according to the platform's default character encoding, use the print(char) or println(char) methods. 
Overrides:
write in class FilterOutputStream
Parameters:
buf - A byte array
off - Offset from which to start taking bytes
len - Number of bytes to write
See Also:
FilterOutputStream.write(int)

解决方案 »

  1.   

    我觉得问题可能在于你们两台机器System.getProperty("file.encoding"),也就是系统默认的编码方式是不一样的。
      

  2.   

    InetAddress addr = InetAddress.getByName(null);
    System.out.println("addr= " + addr);
    socket = new Socket(addr, port);
    Socket的第一个参数是服务器的地址,可你写的是客户端的地址
      

  3.   

    你读了这句没有Note that the bytes will be written as given; to write characters that will be translated according to the platform's default character encoding, use the print(char) or println(char) methods.