Code:
String dir = //Path to the directory
File saveDir = new File(dir);
//Here comes the existence check
if(!saveDir.exists())
saveDir.
FileChannel.lock() does just what you want as long as it's not another thread in the JVM that's deleting the directory while you're using in. This thing demandes a OS lock on a file/folder on behalf of the JVM process, so while other processes will not be able to access that directory, threads in the JVM can.