This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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: 8836
    
    7

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]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to determine weather a file is in use?
 
Similar Threads
Dynamic Background Colors
how to set read & write atteribute of files?
How Writing information to a database
what is applicationResources. properties
Height and width of image from file upload