
{filelink=9024}
import org.apache.commons.net.ftp.FTPClient;
import java.io.IOException;
import java.io.FileOutputStream;
public class FTPDownload
{
public static void main(String[] args) throws Exception
{
FTPClient client = new FTPClient();
client.connect("ftp.exemple.com");
boolean login = client.login("admin", "******");
// Quitter le programme si la connexion a échouée
if (!login)
{
System.out.println("La connexion à échouée");
// Quitter le programme
System.exit(0);
}
// Télécharger le fichier index.php
String fichier = "index.php";
FileOutputStream stream_out = new FileOutputStream(fichier);
client.retrieveFile("/" + fichier, stream_out);
// Fermer le flux et la connexion FTP
stream_out.close();
client.disconnect();
}
}