通过android连接到FTP服务器时出现问题?
当我使用此方法从ddms上载文件时,出现了一个通过android连接到FTP服务器时出现问题?,android,file-upload,ftp,Android,File Upload,Ftp,当我使用此方法从ddms上载文件时,出现了一个未知后异常: try { SimpleFTP ftp = new SimpleFTP(); // Connect to an FTP server on port 21. ftp.connect("ftp://*******", 21, "*****", "*****"); // Set binary mode. ftp.bin(); // Change to a new working directory on the FTP server.
未知后异常
:
try {
SimpleFTP ftp = new SimpleFTP();
// Connect to an FTP server on port 21.
ftp.connect("ftp://*******", 21, "*****", "*****");
// Set binary mode.
ftp.bin();
// Change to a new working directory on the FTP server.
ftp.cwd("web");
// Upload some files.
ftp.stor(new File("data/data/com.android/file/contacts"));
// Quit from the FTP server.
ftp.disconnect();
}
catch (IOException e) {
// Jibble.
}
这种方法有什么问题?任何人都可以澄清我的问题。粗略地看一下,您需要使用主机名,而不使用
ftp://
前缀。还要确保在清单中包含INTERNET权限。在android emulator上使用FTP存在两个主要问题:
如果你想在Android上测试FTP,你需要有一个自己连接互联网的设备。你应该包括logcat@David奥尔森:如何包括logcat。请告诉我方法。在终端中使用adb logcat。或者eclipse中的logcat视图。是的,你是对的。如果我们在ftp地址中声明前缀。那么,它就不起作用了。谢谢。太好了!这就是为什么我不上传我的图像与模拟器。现在我明白了。非常感谢你的回答!这个答案在新的Android emulator版本中仍然有效吗?上面提到的链接已经不存在了。请更新。