0

i am trying to overwrite a file on FTP, but i am getting the error that file is being used by other process while posting.because on FTP, customer's API is reading the file which i am trying to overwrite.Is there any way i can check in my JAVA code that if a file is busy/locked by other processes ? so that i can retry posting once the file is not busy or locked ?

Niraj Sonawane
  • 10,225
  • 10
  • 75
  • 104

1 Answers1

0

Welcome to StackOverflow

You can use java.nio.channels.FileChannel to check if file is lock or not. Java Doc

You can use tryLock method.

Hope this helps

Niraj Sonawane
  • 10,225
  • 10
  • 75
  • 104