를 사용하여 라이브러리 commons.apache.org/proper/commons-net
확인이 FTP 서버에서 파일을 다운로드 :
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();
}
}
}
안녕, 내 바탕 화면에서 FileZilla의 FTP 서버를 설치했습니다. 그것의 주소는 127.0.0.1이고, 포트는 14147입니다. UserName, Password, fileName, localfile에 무엇을 주어야합니까 ?? –
이 링크를 사용하여 http://lifehacker.com/339887/build-a-home-ftp-server-with-filezilla를 사용하여 filezilla로 사용자를 만들고 & 사용 방법을 알 수 있습니다. 또는 동일한 설정을 확인하십시오 http://www.addictivetips.com/windows-tips/how-to-setup-personal-ftp-server-using-filezilla-step-by-step-guide/ –
도서관은 무엇입니까? ??? 나는 org.apache.commons.net.ftp.FTP.sendCommand (FTP.java:471)에서 java.lang.NullPointerException을 얻고있다. –