我想问一下是否有人知道FTP的任何Java 7问题?我已经使用了Sun Net和Apache Commons Net库,并且都在Java 6上按预期执行.但是当我将我的开发环境(Eclipse)切换到1.7时,相同的操作执行速度非常慢(大约4.5到8KB/s),这些是本地主机服务器和局域网内的另一台服务器.
我尝试过缓冲流,字节到字节传输,关闭Nagle算法,并使用Apache便捷方法storeFile(),后者最终执行以加速localhost,但再次减速到远程服务器上的爬行.我还设置所有机器关闭状态FTP过滤.
InputStream is = null;
OutputStream os = null;
try {
is = new BufferedInputStream(prepareInputStream(data));
os = new BufferedOutputStream(prepareOutputStream(data));
if (is == null || os == null) {
log.error("Can't build connection");
return;
}
byte[] buf = new byte[4096];
int c = 1;
while (c > 0) {
c = is.read(buf);
if (c > 0)
os.write(buf, 0, c);
data.incrCurrentPosition();
fireStateChanged(data);
}
data.incrCurrentPosition();
} catch (IOException e) {
log.error(e.getMessage(), e);
setEnabled(false);
} catch (Exception e) { …Run Code Online (Sandbox Code Playgroud)