Bonjour,

J'ai un problème sur un programme en java SE qui scrute le contenue d'un répertoire et quand il détecte un nouveau évènement il l'envoie le fichier par ftp.

Mon problème est que mon programme me génère une erreur, mais mon fichier est bien envoyé :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
 
org.apache.commons.net.io.CopyStreamException: IOException caught while copying.
	at org.apache.commons.net.io.Util.copyStream(Util.java:135)
	at org.apache.commons.net.ftp.FTPClient._storeFile(FTPClient.java:625)
	at org.apache.commons.net.ftp.FTPClient.__storeFile(FTPClient.java:593)
	at org.apache.commons.net.ftp.FTPClient.storeFile(FTPClient.java:1903)
	at com.scanmatch.folderscruteur.thread.impl.EnvoieFTP.run(EnvoieFTP.java:67)
Caused by: java.net.SocketException: Connection reset by peer: socket write error
	at java.net.SocketOutputStream.socketWrite0(Native Method)
	at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:109)
	at java.net.SocketOutputStream.write(SocketOutputStream.java:153)
	at220-FileZilla Server version 0.9.40 beta
Ma classe 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
 
public class EnvoieFTP extends Thread {
 
    private FtpConfigurationParameters ftpConfigurationParameters;
    private String fileNameToUpload;
    private String path = "D:/TestWebservice/temp/";
 
    public EnvoieFTP(FtpConfigurationParameters ftpConfigurationParameters, String filNameToUpload) {
        this.fileNameToUpload = filNameToUpload;
        this.ftpConfigurationParameters = ftpConfigurationParameters;
        this.setDaemon(true);
        this.start();
    }
 
    @Override
    public void run() {
 
 
        FTPClient client = new FTPClient();
        client.addProtocolCommandListener(new PrintCommandListener(new PrintWriter(System.out)));
        String host = "192.168.2.144";
        String username = "plopinou";
        String password = "plopinou";
        FileInputStream in = null;
        try {
            this.sleep(5000);
            client.connect(host);
            int reply = client.getReplyCode();
            System.out.println("Reply code for connection : " + reply);
            if (!FTPReply.isPositiveCompletion(reply)) {
                client.disconnect();
                System.err.println("FTP server refused connection.");
 
            }
            client.login(username, password);
 
            client.setFileType(FTPClient.BINARY_FILE_TYPE);
            client.enterLocalPassiveMode();
 
            path = path + fileNameToUpload;
            in = new FileInputStream(new File(path));
 
 
            System.out.println("FILE TO UPLOAD : " + fileNameToUpload);
            client.storeFile(fileNameToUpload, in);
            System.out.println("Reply code for storefile : " + client.getReplyCode());
            in.close();
 
 
        } catch (SocketException ex) {
            System.out.println("exception SocketException : " + client.getReplyCode());
            ex.printStackTrace();
 
        } catch (IOException ex) {
            System.out.println("Exception : " + client.getReplyCode());
            ex.printStackTrace();
        } catch (InterruptedException ex) {
            System.out.println(ex.getMessage());
        } finally {
            try {
                client.disconnect();
            } catch (IOException ex) {
                ex.printStackTrace();
            }
        }
    }
}
Merci de m'avoir lu.