I have a non-Java program writing files to a directory. My Java program then copies these files to a different directory. Is there a way for Java to check if the last file is fully written to before being copied? This is because when I copy the files, the last file is still being written/processed to by the other program and the Java copy results in only a partial copy of it.
I have looked at doing something like this (Taken from answer here: https://stackoverflow.com/a/17603619/19297684):
boolean success = potentiallyIncompleteFile.renameTo(stagingAreaFile);
where the program attempts to rename the last file. However, this is not platform agnostic.