gpt4 book ai didi

java - 使用 jcifs 复制文件需要很长时间

转载 作者:行者123 更新时间:2023-11-30 11:26:10 31 4
gpt4 key购买 nike

我正在将远程文件从 Windows 共享文件夹复制到 Linux 机器。复制需要很长时间。在 320 MB 中,10 小时内仅复制了 200 Kb。

这是我的代码片段:

try {
String user = "xxxx";
String pass ="yyyy";
NtlmPasswordAuthentication auth = new NtlmPasswordAuthentication("",
user, pass);
String sharepath ="smb://aa.bb.com/root/Test/Access.mdb";
SmbFile remoteFile = new SmbFile (sharepath, auth);

OutputStream os = new FileOutputStream("/home/test/Access.mdb");
InputStream is = remoteFile.getInputStream();
int ch;
while ((ch = is.read()) != -1) {
os.write(ch);
}
os.close();
is.close();

} catch (Exception e) {
e.printStackTrace();

}

如何减少复制时间?

最佳答案

如果复制 200KB 需要 10 小时,那么您的设置有严重问题。可能存在网络问题,或者您的代码和设置可能会触发 jcifs 或 Windows 中的错误。启用所有日志记录,并可能使用调试器和配置文件来查看时间花在了哪里。

作为快速解决方法,您可以考虑使用不同的协议(protocol),例如 SSH 或 rsync with SSH。

或者看看像 XtreemFS 这样的远程文件系统(不过,在你的情况下可能有点矫枉过正)。

关于java - 使用 jcifs 复制文件需要很长时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19924662/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com