0
XMLファイルをftpからアンドロイドフォンメモリにダウンロードするために次のコードを使用しました。ftpに接続できるが、ローカルメモリにXMLを取得しているときに例外が発生します。07-19 15:01:03.721:DEBUG/SntpClient(61) :要求時に失敗しました:java.net.SocketExceptionが:アドレスファミリは誰か助けてくださいプロトコル でサポートされていないあなたに感謝し、次のアンドロイドコードを使用してftpからxmlファイルをダウンロードするには?
Javaクラス
private void fnfileDownloadBuf()
{
FTPClient client = new FTPClient();
FileOutputStream fos = null;
try {
//client.connect("ftp://ftp.qualityinaction.net/QIA/Questions/Airlines/");
client.connect("ftp.qualityinaction.net");
client.login("qualityinaction.net","password");
client.setFileType(FTP.BINARY_FILE_TYPE);
//
// The remote filename to be downloaded.
//
// String filename = "/QIA/Questions/Airlines/index.xml";
String filename = getFilesDir().getAbsolutePath()+ File.separator + "/index.xml";
// String filename = "/QIA/Questions/Airlines/index.xml";
File file = new File(filename);
fos = new FileOutputStream(file);
//
// Download file from FTP server
//
//client.retrieveFile("/" + filename, fos);
client.retrieveFile("/QIA/Questions/Airlines/index.xml;type=i", fos);
// client.retrieveFile(getFilesDir().getAbsolutePath()+ File.separator + "/index.xml", fos);
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (fos != null) {
fos.close();
}
client.disconnect();
} catch (IOException e) {
e.printStackTrace();
}
}
}
マニフェストXMLファイル
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
例外
あなたはパッシブモードを使用する必要があり、そのためのexception 07-19 15:01:03.721: DEBUG/SntpClient(61): request time failed: java.net.SocketException: Address family not supported by protocol
コピーと、Googleの検索ボックスにエラーを貼り付け – Randroid
おかげ応答のために、私は何もしていないよ、私はチェックして、私に解決策を教えてください –