这个不是由于ascii和binary的问题,主要是Linux和Windows的换行符是不一样
所致

解决方案 »

  1.   

    如果是ascii模式,你可以在接收了每一行之后只插入\r不要\r\n
      

  2.   

    多出那个^M是必然的,两个系统对回车换行的理解是不一样的
    用bi可以指定上传用二进制方式对于已经上传了文件,你可以在vi中,用:
    :%s/^V^M//g
    把所有的^M都删除掉!
      

  3.   

    接受ascii和binary文件,应该用不同的流读取,
    你可以先判断文件的类型,然后根据类型:
    ascii用 BufferedReader或其他Reader 来读取;
    bin用 DataInputStream来读取。
      

  4.   

    import java.io.*;
    import sun.net.ftp.FtpClient;public class FtpExample {  public static void main(String args[]) throws Exception {    FtpClient fc;    String host = args[0];
        String path = args[1];
        String username = args[2];
        String password = args[3];    int lastSlash = path.lastIndexOf('/');
        String filename = path.substring(lastSlash+1);
        String directory = path.substring(0,lastSlash);    FtpClient client = new FtpClient(host);
        client.login(username, password);
        client.binary();
        client.cd(directory);    InputStream is = client.get(filename);
        BufferedInputStream bis = new BufferedInputStream(is);    OutputStream os = new FileOutputStream(filename);
        BufferedOutputStream bos = new BufferedOutputStream(os);    byte[] buffer = new byte[1024];
        int readCount;    System.out.println("Getting: " + filename);
                        
        while( (readCount = bis.read(buffer)) > 0) {
          bos.write(buffer, 0, readCount);
        }
        bos.close();
    //    client.closeServer();
      }
    }
      

  5.   

    http://java.sun.com/docs/books/tutorial/networking/