Kullanım kütüphanesi commons.apache.org/proper/commons-net
Kontrol FTP sunucusundan dosya indirmek için:
private Boolean downloadAndSaveFile(String server, int portNumber,
String user, String password, String filename, File localFile)
throws IOException {
FTPClient ftp = null;
try {
ftp = new FTPClient();
ftp.connect(server, portNumber);
Log.d(LOG_TAG, "Connected. Reply: " + ftp.getReplyString());
ftp.login(user, password);
Log.d(LOG_TAG, "Logged in");
ftp.setFileType(FTP.BINARY_FILE_TYPE);
Log.d(LOG_TAG, "Downloading");
ftp.enterLocalPassiveMode();
OutputStream outputStream = null;
boolean success = false;
try {
outputStream = new BufferedOutputStream(new FileOutputStream(
localFile));
success = ftp.retrieveFile(filename, outputStream);
} finally {
if (outputStream != null) {
outputStream.close();
}
}
return success;
} finally {
if (ftp != null) {
ftp.logout();
ftp.disconnect();
}
}
}
Hi, benim masaüstü FileZilla FTP sunucusu yüklendi. Adresi 127.0.0.1, Port 14147'dir. Kullanıcı Adı, Şifre, dosyaAdı, localfile için ne vermem gerekiyor? –
Bu bağlantıyı kullanarak http://lifehacker.com/339887/build-a-home-ftp-server-with-filezilla filezilla içeren bir kullanıcı oluşturmak ve nasıl kullanılacağını bilmek için kullanın. VEYA aynı kurulumları kontrol edin http://www.addictivetips.com/windows-tips/how-to-setup-personal-ftp-server-using-filezilla-step-by-step-guide/ –
Kütüphane nedir? kullanıyorsun ??? Java.lang.NullPointerException adresine org.apache.commons.net.ftp.FTP.sendCommand adresinden ulaşıyorum (FTP.java:471) –