1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
| /*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package ftp;
/**
*
* @author Administrateur
*/
import java.net.SocketException;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.commons.net.ftp.FTPClient;
import java.io.FileInputStream;
import java.io.IOException;
public class Main {
public static void main(String[] args) {
try {
FTPClient client = new FTPClient();
FileInputStream fis = null;
client.connect("domaine ftp");
client.login("user", "mot de passe");
String filename = "c:/degage.avi";
fis = new FileInputStream(filename);
client.storeFile("degage.avi", fis);
client.logout();
fis.close();
} catch (SocketException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
}
} |
Partager