Android Eclipse中的FTP [英] FTP in Android Eclipse
问题描述
您好,我需要紧急帮助,我正在尝试连接到FTP服务器,但它在
mFTPClient = new FTPClient();
爆炸
当我将鼠标悬停在FTPClient()上时出现此错误;
报价:注意:该元素既未附加源代码,也未附加Javadoc,因此找不到Javadoc.
我已经从 http://commons.apache.org/net/download_net.cgi 下载了库文件. a> [^ ]
完整的连接方法是
public boolean ftpConnect(字符串主机,字符串用户名,字符串密码, int 端口){
尝试 {
mFTPClient = 新 FTPClient();
// 连接到主机
mFTPClient.connect(主机,端口);
现在,// 如果肯定的表示成功连接成功,则检查回复代码
如果(FTPReply.isPositiveCompletion(mFTPClient.getReplyCode())){
// 使用用户名&登录.密码
布尔 status = mFTPClient.login(用户名,密码);
/* 设置文件传输模式
*
*为避免损坏问题,您必须指定正确的
*传输模式,例如ASCII_FILE_TYPE,BINARY_FILE_TYPE,
* EBCDIC_FILE_TYPE .etc.在这里,我使用BINARY_FILE_TYPE
*用于传输文本,图像和压缩文件.
*/
mFTPClient.setFileType(FTP.BINARY_FILE_TYPE);
mFTPClient.enterLocalPassiveMode();
Toast.makeText(getBaseContext()," ,Toast.LENGTH_LONG).show() ;
返回状态;
}
} 捕获(异常e){
Toast.makeText(getBaseContext()," + e + " + host,Toast.LENGTH_LONG).show();
}
返回 false;
}
请,因为我还是Android和Java开发的新手,将不胜感激
吐司只是用于设备测试,我可以看到它在哪里成功和失败
亲切的问候
A.J Bosch
PLease跟随该链接,它将引导您获得有关Android中FTP的完整示例:
Android中的FTP
问候...
Hi there I need Urgent help please I am trying to connect to a FTP server but it bombs out at
mFTPClient = new FTPClient();
with this error when I mouse over FTPClient();
Quote:Note: This element neither has attached source nor attached Javadoc and hence no Javadoc could be found.
I Have downloaded the library file for
import org.apache.commons.net.ftp.*;
From http://commons.apache.org/net/download_net.cgi[^]
The full connection method is
public boolean ftpConnect(String host, String username,String password, int port){
try {
mFTPClient = new FTPClient();
// connecting to the host
mFTPClient.connect(host, port);
// now check the reply code, if positive mean connection success
if (FTPReply.isPositiveCompletion(mFTPClient.getReplyCode())) {
// login using username & password
boolean status = mFTPClient.login(username, password);
/* Set File Transfer Mode
*
* To avoid corruption issue you must specified a correct
* transfer mode, such as ASCII_FILE_TYPE, BINARY_FILE_TYPE,
* EBCDIC_FILE_TYPE .etc. Here, I use BINARY_FILE_TYPE
* for transferring text, image, and compressed files.
*/
mFTPClient.setFileType(FTP.BINARY_FILE_TYPE);
mFTPClient.enterLocalPassiveMode();
Toast.makeText(getBaseContext(),"Connected!!",Toast.LENGTH_LONG).show();
return status;
}
} catch(Exception e) {
Toast.makeText(getBaseContext(),"failed "+e+"/r/n Could not connect to"+host,Toast.LENGTH_LONG).show();
}
return false;
}
please as I am still new to android and java development ANY help would be appreciated
The toast''s are just for device test that I am able to see where it succeeds and where it fails
Kind Regards
A.J Bosch
PLease follow that link which will guide you to full example about FTP in android :
FTP in Android
Regards...
这篇关于Android Eclipse中的FTP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!