FTP上传文件 SocketException: Connection reset

来源:互联网 发布:淘宝店铺入口图 编辑:程序博客网 时间:2024/05/01 20:40

FTP上传文件报的异常,我基本代码如下:

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) {    }}


在storeFile 方法会报异常throws a java.net.SocketException:

这是一个java 7 在windows上的bug

解决办法:

 用administrator用户登陆使用命令行执行:

netsh advfirewall set global StatefulFTP disable
即可。


1 0
原创粉丝点击