How to check if a file is open by another process (Java/Linux)?-Collection of common programming errors
You can run from Java program the lsof
Unix utility that tells you which process is using a file, then analyse its output. To run a program from Java code, use, for example, Runtime
, Process
, ProcessBuilder
classes. Note: your Java program won’t be portable in this case, contradicting the portability concept, so think twice whether you really need this 🙂