0
private Boolean downloadAndSaveFile(String server, int portNumber,String user, String password) throws IOException {
FTPClient ftp = null;
// path of a file which is on a web server
String remoteFile1 = "/public_html/1/c language/Unit_1_HTML_and_Forms.pdf";
// Path of my device
File downloadFile1 = new File("/storage/emulated/0/a/new.pdf");
try {
ftp = new FTPClient();
ftp.connect(server, portNumber);
ftp.login(user, password);
ftp.setFileType(FTP.BINARY_FILE_TYPE);
ftp.enterLocalPassiveMode();
System.out.println("Reached passive");
OutputStream outputStream1 = new BufferedOutputStream(new FileOutputStream(downloadFile1));
System.out.println("Stream Created");
boolean success = ftp.retrieveFile(remoteFile1, outputStream1);
System.out.println(success);
return true;
} catch(Exception e) {
System.out.println(e);
} finally {
if (ftp != null) {
ftp.logout();
ftp.disconnect();
}
}
return true;
}
ありがとうございましたありがとうございました:-) – Shyamal
答えを受け入れるのですか?ありがとう! – efekctive