0

I have one server which transfer the files to my directory periodically. I want to transfer these files to another directory. But i have to check whether any file is open or not at server, because i want to prevent the transfer of open files.

If there anyway in java to check whether file is open or not.

You can also suggest any jni lib in worst case.

Greesh Kumar
  • 1,847
  • 3
  • 27
  • 44
  • 3
    http://stackoverflow.com/questions/1390592/java-check-if-file-is-already-open ? – Evers Feb 10 '16 at 12:54
  • boolean isFileUnlocked = false; try { org.apache.commons.io.FileUtils.touch(yourFile); isFileUnlocked = true; } catch (IOException e) { isFileUnlocked = false; } if(isFileUnlocked){ // Do stuff you need to do with a file that is NOT locked. } else { // Do stuff you need to do with a file that IS locked } This code is not working...can you provide a working code for this???? – Haresh Masand Feb 11 '16 at 08:05

0 Answers0