Я пытаюсь скачать базу данных с фтп, но она скачивается поврежденной. Файлы с другими расширениями скачиваются нормально
import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.ftp.FTPFile;
import java.io.FileOutputStream;
import java.io.IOException;
public class Ftp {
public static void main(String[] args) {
FTPClient client = new FTPClient();
String server = "exampleip";
int port = 21;
String user = "examplename";
String pass = "example";
String remoteFilePath = "/example/example/example.db";
String localFilePath = "C:/example/example/example/example.db";
try {
client.connect(server, port);
client.login(user, pass);
client.enterLocalPassiveMode();
FTPFile[] files = client.listFiles(remoteFilePath);
if (files.length > 0) {
FileOutputStream fos = new FileOutputStream(localFilePath);
client.retrieveFile(remoteFilePath, fos);
fos.close();
}
client.logout();
client.disconnect();
} catch (IOException e) {
e.printStackTrace();
}
}
}
С Ftp все нормально, проверял мой друг. Также он скачивал этот файл, и он был не повреждён.
Источник: Stack Overflow на русском