java.net.SocketException: Software caused connection abort: recv failed
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:152)
at java.net.SocketInputStream.read(SocketInputStream.java:122)
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:314)
at org.apache.commons.net.ftp.FTP.__getReply(FTP.java:294)
at org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:483)
at org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:608)
at org.apache.commons.net.ftp.FTP.port(FTP.java:932)
at org.apache.commons.net.ftp.FTPClient._openDataConnection_(FTPClient.java:812)
at org.apache.commons.net.ftp.FTPClient._storeFile(FTPClient.java:633)
at org.apache.commons.net.ftp.FTPClient.__storeFile(FTPClient.java:624)
at org.apache.commons.net.ftp.FTPClient.storeFile(FTPClient.java:1976)
大神帮忙看看怎么回事。。。。
public void testFtpClient() throws Exception{
//创建一个ftp客户端对象
FTPClient ftpClient = new FTPClient();
//创建ftp连接
ftpClient.connect("192.168.32.128",21);
//登录ftp服务器,使用用户名和密码
ftpClient.login("ftpuser","localhostftp123");
//上传文件
//第一个参数,服务器文档名,第二个参数:上传文档的inputstream
//读取一个本地文件
//设置上传路径
FileInputStream stream = new FileInputStream(new File("C:\\Users\\016\\Desktop\\20170120170522.jpg"));
ftpClient.changeWorkingDirectory("/home/ftpuser/images/img");
ftpClient.storeFile("hello1.jpg",stream);
//关闭连接
ftpClient.logout();
stream.close();
}
3 个解决方案
#1
都回家过年了吗,都没大牛来解决下
#2
ftp服务器的协议和代码的协议不一致
#3
协议?能说明白点吗?兄弟
#1
都回家过年了吗,都没大牛来解决下
#2
ftp服务器的协议和代码的协议不一致
#3
协议?能说明白点吗?兄弟