Java – FileUtils. Java for large files Copyfile failed

I have a simple java application that tries to copy files over Wan (from Ireland to New York)

I recently modified it to use FileUtils because native java file copies are too slow I studied and found that FileUtils is better because it uses NiO The file copy works well now, but occasionally I need to copy a very large file (> 200MB) and the copy fails with an error:

java.io.IOException: Failed to copy full contents from...

I knew that the error meant that the target file size was different from the source, so at first I thought it was a network problem The process repeatedly tries to copy the file every few hours, but it will never succeed However, it works well when I manually copy files through a Windows browser This seems to rule out the Internet... But I'm not sure

I have searched but can't find any posts with the same question Any help would be appreciated

thank you!

Bonus: I'm using this FileUtils method:

public static void copyFile(java.io.File srcFile,java.io.File destFile) throws java.io.IOException

Solution

So I found the problem in the target folder There is a polling process, assuming that files are picked up after copying However, the file was moved before the copy was complete This may not happen on the windows drive because the file will be locked (I test locally and I can't delete the file while copying) However, the destination folder is the installed Celera share UNIX processes under the hood grab files... I don't think it cares if some windows processes are still writing to it

Thank you for your time medphys PL!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>