• Post Reply Bookmark Topic Watch Topic
  • New Topic

Locking directory  RSS feed

 
bharathk Kumar
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1970
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!