aspose file tools*
The moose likes I/O and Streams and the fly likes How to determine weather a file is in use? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "How to determine weather a file is in use?" Watch "How to determine weather a file is in use?" New topic
Author

How to determine weather a file is in use?

vijay mahendra
Ranch Hand

Joined: Jan 01, 2007
Posts: 51
hi all,

how to determine whether file is in use?

using java code.Please help me in this.
Thanks,
Vijay
Sev Zaslavsky
Greenhorn

Joined: Nov 19, 2008
Posts: 7
Vijay, what do you mean by "in use"? Is it the same as "cannot be written?" java.io.File class has some methods for determining the status of files.
Neha Kathuriaa
Greenhorn

Joined: Sep 16, 2008
Posts: 25
what are those methods?
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8927
    
    9

Are you familiar with the Java API documentation?
If you want to know if a file is being written, you can watch for a change in the file size. I'm not aware of any way to tell if a file is being read.
It is possible to do file locking with Java. Depending on your requirements, that may be an option.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
 
wood burning stoves
 
subject: How to determine weather a file is in use?