日期:2014-05-19  浏览次数:20763 次

使用commons-net 的 ftp上传文件速度怎么这么慢?

使用commons-net 的 ftp上传一个100K的文件要20几秒,
使用FTP工具,两秒就搞定了,速度怎么这么慢?

------解决方案--------------------
我上传20M也就3秒而已,应该是你网络问题之类。你就先写一个简单的类开始,直接从FileInputStream开始上传


FTPClient client = new FTPClient();
client.connect("。。");
client.login("。。");
long t1 = System.currentTimeMillis();
client.storeFile("A.exe", new BufferedInputStream(new FileInputStream("a.exe")));
long t2 = System.currentTimeMillis();
System.out.println("Time:" + (t2 - t1));
client.quit();


都是打印3000左右,20M的文件
------解决方案--------------------
是不是这样的,通过别的机器上传的时候需要先经过http上传到服务器,然后再通过ftp上传至指定的服务器,所以最好做个客户端来直接实现上传