Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to determine weather a file is in use?

 
vijay mahendra
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,

how to determine whether file is in use?

using java code.Please help me in this.
Thanks,
Vijay
 
Sev Zaslavsky
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what are those methods?
 
Joe Ess
Bartender
Posts: 9311
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic