java – 复制文件时出现无提示错误
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了java – 复制文件时出现无提示错误,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1916字,纯文字阅读大概需要3分钟。
内容图文
我有以下复制文件的方法:
public static void nioCopy(File source, File destination) {
FileInputStream fis = null;
FileOutputStream fos = null;
FileChannel input = null;
FileChannel output = null;
try {
fis = new FileInputStream(source);
fos = new FileOutputStream(destination);
input = fis.getChannel();
output = fos.getChannel();
input.transferTo(0, input.size(), output);
} catch (FileNotFoundException ex) {
Logger.getLogger(Utilities.class.getName()).log(Level.SEVERE, "Can't find either of input/output files.", ex);
} catch (IOException ex) {
Logger.getLogger(Utilities.class.getName()).log(Level.SEVERE, "Can't open either of input/output file for reading/writing", ex);
} finally {
try {
fis.close();
fos.close();
input.close();
output.close();
} catch (IOException ex) {
Logger.getLogger(Utilities.class.getName()).log(Level.SEVERE, "Error closing streams", ex);
}
}
}
我正在使用复制文件但有时我得到一个无声错误或未定义的行为,或者我只是不知道如何解释它,这就是我得到的:
这是我的来源:
-rw-r--r-- 1 nb9 team92 3.1G 2011-10-13 16:31 6443_6#5_1_6443_6#5_2.fastq.f.fq.gz
这是目的地:
-rw-r--r-- 1 nb9 team92 2.0G 2011-10-13 16:49 6443_6#5_1_6443_6#5_2.fastq.f.fq.gz
在执行此过程时我没有异常,并且通过它的外观一切都应该成功但是当我开始解压缩文件时,我得到:
java.io.EOFException:ZLIB输入流的意外结束
显然目的地是原始标记1 gig.
唯一的特点是两个文件都在非常繁忙的光泽文件系统上,这有可能是一些有趣的东西吗?
解决方法:
在2Gb被截断的事实让我怀疑.我搜索它看起来像issue with nio.它也可能是目标文件系统允许最大2Gb文件.
At present, buffer sizes are limited to 2GB (the maximum positive number that can be represented in an int. An updated planned for Java 7 will allow large buffers (with the size and indexes held as a long).
无论如何,只是为了确定:
>如果你有空间,你可以尝试在同一个文件系统上复制它吗?
>您可以尝试使用Apache Commons IO FileUtils.copyFile()吗?似乎他们fixed this issue.
>如果您可以升级,请尝试使用Java 7,因为已经出来了
内容总结
以上是互联网集市为您收集整理的java – 复制文件时出现无提示错误全部内容,希望文章能够帮你解决java – 复制文件时出现无提示错误所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。