my dog learned polymorphism
The moose likes Java in General and the fly likes Locking directory Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Locking directory " Watch "Locking directory " New topic
Author

Locking directory

bharathk Kumar
Greenhorn

Joined: Mar 14, 2006
Posts: 1
Hi

While i am reading the files inside a directory, I need to lock that particular directory so that no new file get added/deleted. Can anyone please let me know how can i go abt.
Peter Chase
Ranch Hand

Joined: Oct 30, 2001
Posts: 1970
Pre Java 6, you can't do this with Java. You'd have needed to call the operating system, via shell or JNI.

In Java 6, you might find java.lang.File.setWritable() does what you want. However, setting a directory unwritable is neither friendly nor reliable.

You'd be much better off thinking of how your application can be redesigned to cope with normal directory behaviour.
[ May 14, 2007: Message edited by: Peter Chase ]

Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.<br /> <br />#:^P
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Locking directory
 
Similar Threads
file handling in java
reading files in specified directory
eclipse, open a file outside a project
View direct through a web service question
How can a program point to a a different directory