FileInputStream fis = new FileInputStream(strSourceFileName);
     BufferedInputStream bis = new BufferedInputStream(fis);
     DataInputStream in = new DataInputStream(bis);
     PrintWriter printWriter = new PrintWriter(outStream,true);     while(true)
     {
       String strFile = in.readLine();
       if (strFile!=null)
       { //这里就是处理中文问题过程;
         strFile = new  String(strFile.getBytes("iso-8859-1"),"GBK");
         printWriter.println(strFile);
       }else break;
     }
     printWriter.println("~END~");

解决方案 »

  1.   

    事实上,如果不处理中文就传送过去,肯定是不对的,我已经做了很多次实验。
    JAVA把双字节的中文字符当成单字节来发送的。
      

  2.   

    谁说“JAVA把双字节的中文字符当成单字节来发送的”?你要把字节和字符的概念搞清楚……直接用字节的话就不会有这些问题了……先把要传输的文件读到一个字节数组中(byte[]),再把这个字节数组写入输出流。在接收端也用一个字节数组来接收,然后再把这个字节数组直接写入文件即可……这样不管你什么文件都不会有问题的……
      

  3.   

    不可能吧?你确定是用BYTE?不是CHAR或STRING来传输的?
      

  4.   

    只要用byte的字节流,就绝对没问题。Socket incoming;
    InputStream in = incoming.getInputStream();
    byte b[] = new byte[buffer];
    in.read(b, offset, length);byte b[]中就是所要的