bonjour,
Voici mon problème, j'utilise actuellement la librairie de apache pour accèder à mon serveur ftp. Mais voila, envoyer, un fichier sur le serveur marche et recuperer, prendre un fichier sur le serveur ne fonctionne pas. Ca me créé un fichier vide au lieu de récupérer le fichier demander.
Voici le code de ma class FTP :
package javaapplication5;
public class MonFTP {
public static FTPClient ftp;
public static void main(String[] args) {
String result;
result = receptionner("D:\\naja\\Intro au génie logiciel\\","monfichier");
System.out.println("Result: " + result);
}
public static String envoyer(String chemin, String nomFichier) {
try {
int reply;
InputStream in = null;
ftp = new FTPClient();
ftp.enterLocalPassiveMode();
ftp.connect("ftpoerso.free.fr");;
ftp.login("log", "password");
System.out.println("Connected to server.");
System.out.print(ftp.getReplyString());
ftp.setFileType(FTP.ASCII_FILE_TYPE);
// After connection attempt, you should check the reply code to verify
// success.
reply = ftp.getReplyCode();;
if (!FTPReply.isPositiveCompletion(reply)) {
ftp.disconnect();
System.exit(1);
}
//File f1 = new File("prout.txt");
File f1 = new File(chemin+"/"+nomFichier+".txt");
in = new BufferedInputStream (new FileInputStream(f1),8);
public static String receptionner(String chemin, String nomFichier) {
try {
int reply;
OutputStream out = null;
ftp = new FTPClient();
ftp.enterLocalPassiveMode();
ftp.connect("ftpoerso.free.fr");
ftp.login("log", "password");
System.out.println("Connected to server.");
System.out.print(ftp.getReplyString());
ftp.setFileType(FTP.ASCII_FILE_TYPE);
// After connection attempt, you should check the reply code to verify
// success.
reply = ftp.getReplyCode();
if (!FTPReply.isPositiveCompletion(reply)) {
ftp.disconnect();
System.err.println("FTP server refused connection.");
System.exit(1);
}
//File f1 = new File(chemin+"/"+nomFichier+".txt");
File f1 = new File(chemin+"/"+nomFichier+".txt");
out = new BufferedOutputStream(new FileOutputStream(f1));
//ftp.retrieveFile(nomFichier+".txt", out);
ftp.retrieveFile(nomFichier+".txt", out);
ftp.logout();
} catch (IOException e) {
e.printStackTrace();
}
return "reussi";
}
}
Et comment je dois faire si c'est un problème de racine?