Hallo,
ich habe eine Java Programm geschrieben, mit dem ich eine Datei per FTP herunterladen kann. Das Programm funktioniert auch einwandfrei.
Hier der Code:
import org.apache.commons.net.ftp.*;
import java.io.*;
public class Net {
public static void main(String[] args) {
try {
FTP ftp = new FTP(host,user,pwd);
ftp.cwdi("/tmp");
ftp.receiveFile(„bla.txt“,"/tmp");
ftp.disconnect();
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
class FTP extends FTPClient {
private FTPClient ftp;
public FTP (String host, String userName, String password) {
try {
ftp = new FTPClient();
ftp.connect(host, 21);
ftp.login(userName, password);
} catch (Exception ex) {
ex.printStackTrace();
}
}
public boolean receiveFile (String serverFile, String localDir) {
try {
FTPFile files[] = ftp.listFiles();
if (files != null) {
for (int i=0; i