IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Entrée/Sortie Java Discussion :

Probleme avec l'API pour faire du FTP


Sujet :

Entrée/Sortie Java

  1. #1
    Membre actif
    Profil pro
    Inscrit en
    Juin 2002
    Messages
    84
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2002
    Messages : 84
    Points : 232
    Points
    232
    Par défaut Probleme avec l'API pour faire du FTP
    Bonjour,

    J'utilise l'API FTP java "edtftpj.jar".
    J'ai le code suivant provenant de Talend, le code n'est pas propre je le sais mais bon c'est un générateur qui l'envoie :

    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
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
     
     
    try {
    	/**
             * [tFTPPut_1 begin ] start
             */
     
    	int nb_file_tFTPPut_1 = 0;
    	com.enterprisedt.net.ftp.FTPClient ftptFTPPut_1 = new   com.enterprisedt.net.ftp.FTPClient();
    	ftptFTPPut_1.setRemoteHost(ftpHost);
    	ftptFTPPut_1.setRemotePort(ftpPort);
    	ftptFTPPut_1.connect();
    	ftptFTPPut_1.login(ftpUser, ftpPwd);
    	java.util.List<java.util.Map<String, String>> listtFTPPut_1 = new java.util.ArrayList<java.util.Map<String, String>>();
    	java.util.Map<String, String> maptFTPPut_10 = new java.util.HashMap<String, String>();
    	maptFTPPut_10.put("fichier-*.txt", "");
    	listtFTPPut_1.add(maptFTPPut_10);
    	String remotedirtFTPPut_1 = new StringBuilder().append(
    		ftpEmplacement).append("erase").append(
    		java.io.File.separator).append("transaction").append(
     		java.io.File.separator).append("temp").append(
    		java.io.File.separator).toString();
    	 ;
    	ftptFTPPut_1.chdir(remotedirtFTPPut_1);
    	ftptFTPPut_1		.setType(com.enterprisedt.net.ftp.FTPTransferType.BINARY);
    			String localdirtFTPPut_1 = repertoireFichierSortieValide;
    			for (java.util.Map<String, String> maptFTPPut_1 :   listtFTPPut_1) {
    		java.util.Set<String> keySettFTPPut_1 = maptFTPPut_1.keySet();
    		for (String keytFTPPut_1 : keySettFTPPut_1) {
    			String tempdirtFTPPut_1 = localdirtFTPPut_1;
    			String filemasktFTPPut_1 = keytFTPPut_1;
    			String dirtFTPPut_1 = null;
    			String masktFTPPut_1 = filemasktFTPPut_1.replaceAll("\\\\",
    				"/");
    	   	        int itFTPPut_1 = masktFTPPut_1.lastIndexOf('/');
    			if (itFTPPut_1 != -1) {
    			dirtFTPPut_1 = masktFTPPut_1.substring(0, itFTPPut_1);
    			masktFTPPut_1 = masktFTPPut_1.substring(itFTPPut_1 + 1);
    			}
    			if (dirtFTPPut_1 != null && !"".equals(dirtFTPPut_1))
    				tempdirtFTPPut_1 = tempdirtFTPPut_1 + "/"
    						+ dirtFTPPut_1;
    			masktFTPPut_1 = masktFTPPut_1.replaceAll("\\.", "\\\\.")
    					.replaceAll("\\*", ".*");
    			final String finalMasktFTPPut_1 = masktFTPPut_1;
    			java.io.File[] listingstFTPPut_1 = null;
    			java.io.File filetFTPPut_1 = new java.io.File(
    				tempdirtFTPPut_1);
    			if (filetFTPPut_1.isDirectory()) {
    			listingstFTPPut_1 = filetFTPPut_1
    			.listFiles(new java.io.FileFilter() {
    			public boolean accept(java.io.File pathname) {
    				boolean result = false;
    				if (pathname !=null && pathname.isFile()) {
    			result = java.util.regex.Pattern.compile(finalMasktFTPPut_1).matcher(pathname.getName())
    .find();
    	}
    	return result;
    	}
    	});
    	}
    	if (listingstFTPPut_1 != null) {
    		for (int mtFTPPut_1 = 0; mtFTPPut_1 < listingstFTPPut_1.length; mtFTPPut_1++) {
    			if (listingstFTPPut_1[mtFTPPut_1].getName().matches(masktFTPPut_1)) {									
     
    			ftptFTPPut_1.put(tempdirtFTPPut_1+ "/"+ listingstFTPPut_1[mtFTPPut_1].getName(),listingstFTPPut_1[mtFTPPut_1].getName());												
                           nb_file_tFTPPut_1++;
    					}
    				}
    			}
    		}
    	}
    	ftptFTPPut_1.quit();
     
     
    	} catch (Exception e) {
    	  e.printStackTrace();
    	}
    Cette méthode sort en exception sur l'instruction "ftptFTPPut_1.quit();" :

    java.io.IOException: Unexpected null reply received
    at com.enterprisedt.net.ftp.FTPControlSocket.readReply(FTPControlSocket.java:855)
    at com.enterprisedt.net.ftp.FTPControlSocket.sendCommand(FTPControlSocket.java:818)
    at com.enterprisedt.net.ftp.FTPClient.quit(FTPClient.java:3488)
    at Test.tFTPPut_1Process(Test.java:130)
    at Test.main(Test.java:22)

    Avez vous déja eu ce problème et comment le résoudre?

    Merci.

    Koko22

  2. #2
    Membre actif
    Profil pro
    Inscrit en
    Juin 2002
    Messages
    84
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2002
    Messages : 84
    Points : 232
    Points
    232
    Par défaut
    J'ai une piste,
    notre serveur FTP Windows ne renvoie pas 221 GOODBYE tandis que celui de Linux le fait.
    Sur Windows, l'API plante. Sur Linux, non.

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Probleme avec POI (API excel pour java)
    Par Frigok dans le forum API standards et tierces
    Réponses: 1
    Dernier message: 06/04/2009, 17h17
  2. [Tableaux] probleme avec mon code pour faire un parseur !
    Par Joe-La-Boule dans le forum Langage
    Réponses: 10
    Dernier message: 11/10/2006, 15h35
  3. [Kylix] Erreur "File not Found : Windows.dcu"
    Par derrick23_2003 dans le forum EDI
    Réponses: 4
    Dernier message: 27/12/2005, 11h18
  4. [SWT] Api pour faire des graph ?
    Par bawan dans le forum SWT/JFace
    Réponses: 1
    Dernier message: 05/09/2005, 13h13
  5. Réponses: 8
    Dernier message: 05/10/2004, 00h02

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo