-1
我正嘗試通過FTP
下載文件與本地Android項目這是我的方法問題與Android的FTP客戶端
@Override protected File doInBackground(Void... params) {
File fileBar = new File(mLocalDir, mFileNameBar);
boolean descargado = false;
FTPClient ftpClient = null;
try {
ftpClient = new FTPClient();
ftpClient.setConnectTimeout(10000);
ftpClient.connect(SERVER, 21);
ftpClient.enterLocalPassiveMode();
ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
if (ftpClient.login(mUser, mPass)) {
ftpClient.changeWorkingDirectory("/Almacen");
FileOutputStream fileOutputStreamBar;
fileOutputStreamBar = new FileOutputStream(fileBar, false);
OutputStream outputStreamBar = new BufferedOutputStream(fileOutputStreamBar);
FileOutputStream fileOutputStreamPec;
fileOutputStreamPec = new FileOutputStream(filePec, false);
OutputStream outputStreamPec = new BufferedOutputStream(fileOutputStreamPec);
descargado = ftpClient.retrieveFile(mFileNameBar, outputStreamBar);
}
} catch (IOException e) {
System.out.println(e.toString());
fileArt = null;
} finally {
if (ftpClient != null && ftpClient.isConnected()) try {
ftpClient.logout();
} catch (IOException ignored) {
}
if (ftpClient != null) try {
ftpClient.disconnect();
} catch (IOException ignored) {
}
}
return (descargado ? fileArt : null);
}
的方法可以正常工作,或者至少我是這麼認爲的。它下載所需的文件,但不佔用32Kb,而是佔用24Kb。 我不明白爲什麼會發生這種情況。如果有人能幫我一把,我會非常感謝
哦,它的工作原理!謝謝!! – ZamoraFTW
不客氣。請接受答案(V):) – ApriOri
(我正在嘗試,我不得不等待。)再次感謝^^ – ZamoraFTW