I reslove it at last.

add
 ftpClient.enterLocalPassiveMode();
before storeFile();

ftpClient.connect(InetAddress.getByName(server));
                                        ftpClient.login(user, password);

                                        
ftpClient.changeWorkingDirectory(serverRoad);
                                        
ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
                                        BufferedInputStream buffIn=null;
                                    buffIn=new BufferedInputStream(new 
FileInputStream(file));
                                    ftpClient.enterLocalPassiveMode();
                                    ftpClient.storeFile("test.txt", buffIn);
                                    buffIn.close();
                                    ftpClient.logout();
                                    ftpClient.disconnect();


On Dec 24, 2:07 pm, tonyant <[email protected]> wrote:
> Hi ,all
>   when I run those code,
>
>    FTPClient ftpClient = new FTPClient();
>         ftpClient.connect(InetAddress.getByName(server));
>         ftpClient.login(username, password);
>         Log.d("FTP",ftpClient.getReplyString());
>         ftpClient.changeWorkingDirectory(serverRoad);
>         ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
>         BufferedInputStream buffIn=null;
>          buffIn=new BufferedInputStream(new FileInputStream
> (fileRoad));
>         ftpClient.storeFile(newFileName, buffIn);
>         buffIn.close();
>         ftpClient.logout();
>         ftpClient.disconnect();
>
> it works fine in the common java env. and the file is upload to theftpserver. 
> However, When it run in android, It thrown  exception:
> WARN/System.err(929):
> org.apache.commons.net.ftp.FTPConnectionClosedException: Connection
> closed without indication.
>
> Do someone have a successfulftpupload code, thank very much if
> share.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to