Bonjour à tous,
je voudrais envoyer un fichier sur un serveur j'ai fais une classe java qui me permet de me connecter à mon serveur mais je ne vois pas comment il faut faire pour y déposer mon fichier. Voila mon code si quelqu'un à une solution merci de partager:
j'utilise sendCommand pour envoyer ma commande pour uploader le doc mais je crois que c'est pas la solution.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 import java.io.*; import java.net.*; //import java.util.*; import org.apache.commons.net.ftp.*; public class ClientFTP { public static void main(String[] args) { String[] ft = null; FTPClient clientFtp = new FTPClient(); try { clientFtp.connect("00.000.0.000"); System.out.println("Connecté"); if ( clientFtp.login("XXXX", "XXXX") ){ System.out.println("Identification réussie !"); } clientFtp.sendCommand("get","doc.txt"); ft = clientFtp.listNames(); //clientFtp.logout(); //clientFtp.logout(); } catch (UnknownHostException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } int i; for(i=0;i<ft.length;i++){ System.out.println("fichier num " + i + " " + ft[i]); } } }








Répondre avec citation
Partager