File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Locking files in java. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Locking files in java." Watch "Locking files in java." New topic

Locking files in java.

sneha ulhe
Ranch Hand

Joined: May 15, 2012
Posts: 52

Is there any way using which we can lock files in simple java...?

[OCJP 6]
Henry Wong

Joined: Sep 28, 2004
Posts: 20521

Never had the need to do this myself, so take with a grain of salt.... Take a look at the FileChannel and FileLock classes.


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Vishal Shaw
Ranch Hand

Joined: Aug 09, 2012
Posts: 179
Hi Sneha,

Did you tried the . Hope it helps


Programming is about thinking, NOT coding
It is sorta covered in the JavaRanch Style Guide.
subject: Locking files in java.
It's not a secret anymore!