我正在尝试通过FTP下载本地Android项目的文件
这是我的方法
@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。 我不明白为什么会这样。如果有人能帮助我,我将非常感激