Locking files

The Java program can lock a file to prevent other users from accessing the file while the first Java program is using the file. Lock types are as follows:

To give up the locks obtained through the lock() method, the Java program should invoke the releaseExplicitLocks() method.