This content has been marked as final. Show 2 replies
What is a PrematureEndOfFile exception? I've never seen that before and as far as I know it doesn't exist in the JDK (not even in 7).
Writing files is not an atomic operation, so an FTP server usually creates the file first, then writes the content. This means that just because a file has been created does not mean that the content will be "complete".
The reason you didn't see this when dropping files into a local folder is probably because moves within a file system (= drive in Windows, usually) are atomic, so you won't ever see a "half-moved" file. Try copying into the folder and you should be able to see the same effect (within a shorter time, however since local copies are usually very fast).
There's no reliable way to know when an application is "done" writing a file and NIO2 doesn't change that.
Ideally, you could configure your FTP server to write its files to some temporary name and rename it to the final name once the transfer is complete. Then you can just ignore all events where the name matches the temporary files.
Hi Joachim, thanks for the detailed answer. I didn't remember the exact error message, and my logs had been overwritten, but the error message was something in that vein.
I'll try to get the FTP server configured, like you suggested. Thanks again.