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 39 40 41 42 43 44 45 46 47
|
public class Fenetre extends JFrame{
private JPanel pPrincipal = new JPanel();
public Fenetre(){
this.setTitle("Upload");
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setSize(1200, 600);
this.setResizable(true);
this.setLocationRelativeTo(null);
this.getContentPane().add(pPrincipal);
JFileChooser jfc = new JFileChooser();
try {
FileInputStream fichier = new FileInputStream(jfc.getSelectedFile());
FTPClient ftp = new FTPClient();
int port = 21;
String host = "ftpperso.free.fr";
String username="********";
String password = "*****";
ftp.connect(host,port);
ftp.login(username, password);
ftp.storeFile("po", fichier);
} catch (SocketException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//
this.setVisible(true);
}
} |