Possible to test if file is open in another process?

C

Chris

Is it possible to test if a file is open by another process?

I don't want to lock the file. I just want to know if another process has it
open for any reason.

I'm using JDK 1.4, so NIO is available. I couldn't find any methods that
would do it, though. The closest ones I could find had to do with creating a
FileLock on a channel. But that doesn't help.
 
M

Marc E

maybe you could try renaming the file to itself. if the file is locked, it
should return false
 
C

Chris Smith

Marc E said:
maybe you could try renaming the file to itself. if the file is locked, it
should return false

No, that would depend on the operating system. Without cooperative
locking, there is no way to accomplish the requested task in a portable
way.

--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,816
Latest member
nipsseyhussle

Latest Threads

Top