One simple solution I've used in the past for this scenario with Windows is to use boolean File.renameTo(File)
and attempt to move the original file to a separate staging folder:
boolean success = potentiallyIncompleteFile.renameTo(stagingAreaFile);
If success
is false
, then the potentiallyIncompleteFile
is still being written to.