无法分析android FTP应用程序中的响应代码错误(格式错误的ServerReplyException)

无法分析android FTP应用程序中的响应代码错误(格式错误的ServerReplyException),android,ftp,ftp-client,Android,Ftp,Ftp Client,我想把一个文件从android手机发送到PC。我用下面的代码来完成。这是一个错误: 格式错误的ServerReplyException:无法分析响应代码 请建议 @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow()

我想把一个文件从android手机发送到PC。我用下面的代码来完成。这是一个错误:

格式错误的ServerReplyException:无法分析响应代码

请建议

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    setContentView(R.layout.activity_main);
    FtpConnect();
}

public static void FtpConnect() {
    String userName = "usr";
    String passWord = "pwd";
    String ftpAddress = "192.100.11.10"; // this isnt the ip address I was
                                            // using...
    String retrieveFromFTPFolder = "/mnt/sdcard/DCIM/Camera/Pictures/";
    String strLine;
    DataInputStream inputStream = null; 
    BufferedReader bufferedReader = null;
    FTPClient client = null;
    FTPFile[] ftpFiles = null;
    int reply;

    try {

        client = new FTPSClient();

        Log.e("","CLIENT OBJECT OK...");
        client.setListHiddenFiles(true);
        Log.e("","CLIENT HIDDEN FILES OK...");
        client.setBufferSize(1024);

        client.setConnectTimeout(60000);

        Log.e("","set CLIENT  timeout and buf size OK...");
        client.connect(ftpAddress,22); // this right here is where it fails
        Log.e("","CONNECTION OK...");

        client.login(userName, passWord);
        Log.e("","AUthentication OK...");
        client.setFileType(FTP.BINARY_FILE_TYPE);
        Log.e("","setFIletYPE OK...");
        result=client.storeFile("/mnt/sdcard/DCIM/Camera/2012-05-10 22.14.43.jpeg",inputStream);
        Log.e("RESULT","RESULT : "+result);
        if (!client.completePendingCommand()) {
            client.logout();
            client.disconnect();
            System.err.println("File transfer failed.");
            Log.e("RESULT","RESULT : "+result);
        }

    } catch (Exception e) {
        Log.e("RESULT","Exception : "+e);
        if (client.isConnected()) {
            try {
                client.logout();
                client.disconnect();
            } catch (IOException f) {
                Log.e("RESULT",""+f);
            }
        }
    } finally {
        if (client.isConnected()) {
            try {
                client.logout();
                client.disconnect();
            } catch (IOException f) {
                Log.e("RESULT",""+f);
            }
        }
它正在投掷的是

08-29 12:41:21.452: E/(2111): CLIENT OBJECT OK...
08-29 12:41:21.452: E/(2111): CLIENT HIDDEN FILES OK...
08-29 12:41:21.452: E/(2111): set CLIENT  timeout and buf size OK...
08-29 12:41:24.686: I/global(2111): Default buffer size used in BufferedReader constructor. It would be better to be explicit if an 8k-char buffer is required.
08-29 12:41:24.694: I/global(2111): Default buffer size used in BufferedWriter constructor. It would be better to be explicit if an 8k-char buffer is required.
08-29 12:41:24.882: E/RESULT(2111): Exception : org.apache.commons.net.MalformedServerReplyException: Could not parse response code.
08-29 12:41:24.882: E/RESULT(2111): Server Reply: SSH-2.0-OpenSSH_5.8p1 Debian-7ubuntu1
08-29 12:41:25.014: E/RESULT(2111): org.apache.commons.net.MalformedServerReplyException: Could not parse response code.
08-29 12:41:25.014: E/RESULT(2111): Server Reply: Protocol mismatch.
08-29 12:41:25.014: E/RESULT(2111): org.apache.commons.net.ftp.FTPConnectionClosedException: Connection closed without indication.

这只是因为FTP服务器没有在指定的IP中启动服务器,现在没事了

@navy:也许他是说代码使用了不同的IP(以及端口)。我犯了同样的错误,因为我正在为FTPS和SFTP编写包装,所以我错误地将端口22用于FTPS:-)