I am trying to upload a plain text file via FTP using XAMPP and FileZilla.
I am using Apache Commons Net 3.0.1 Library .
This is my code, very simple things:
FTPClient client = new FTPClient(); InputStream in = new ByteArrayInputStream("IT WORKS! :D".getBytes()); try { client.connect("localhost"); client.login("user", "password"); client.enterLocalPassiveMode(); client.storeFile("textfile.txt", in); } finally { try { in.close(); client.logout(); client.disconnect(); } catch (Exception e) { } }
But ... storeFile () throws java.net.SocketException:
Exception in thread "main" java.net.SocketException: Connection reset at java.net.SocketInputStream.read(SocketInputStream.java:189) at java.net.SocketInputStream.read(SocketInputStream.java:121) at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:283) at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:325) at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:177) at java.io.InputStreamReader.read(InputStreamReader.java:184) at java.io.BufferedReader.fill(BufferedReader.java:154) at java.io.BufferedReader.read(BufferedReader.java:175) at org.apache.commons.net.io.CRLFLineReader.readLine(CRLFLineReader.java:58) at org.apache.commons.net.ftp.FTP.__getReply(FTP.java:310) at org.apache.commons.net.ftp.FTP.__getReply(FTP.java:290) at org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:474) at org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:547) at org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:596) at org.apache.commons.net.ftp.FTP.pasv(FTP.java:945) at org.apache.commons.net.ftp.FTPClient._openDataConnection_(FTPClient.java:719) at org.apache.commons.net.ftp.FTPClient.__storeFile(FTPClient.java:551) at org.apache.commons.net.ftp.FTPClient.storeFile(FTPClient.java:1704) at ftpexample.ftpexample.main(ftpprova.java:17)
What is the problem ?? :( I also tried in the online service, with the same result ...
I wonder if this is a firewall or windows related issue?
Oneiros
source share