I have a Java application that monitors the directory for new files and processes any new file that it sees in the directory. The application should run on both linux and windows env. The problem is Linux, when the user manually copies the file to the directory, the application selects the file before it is fully copied to the directory. I tried to lock the file using various methods , but the application can get a lock in the file, even if the file is still copied by the linux system. I am also considering checking the file with the lsof command , but it is specific to Linux, so I try to avoid this.
Can anyone suggest a way to prevent the file from being downloaded by the application? Thanks in advance.
source
share