Code example for FileLock

Methods: isValidrelease

0
    /** 
     * @tests java.nio.channels.FileChannel#lock(long,long,boolean) 
     */ 
    public void test_lockJJZ_After_Release() throws Exception {
        fileLock = writeOnlyFileChannel.lock(0, 10, false);
        fileLock.release();
        // after release file lock can be obtained again. 
        fileLock = writeOnlyFileChannel.lock(0, 10, false);
        assertTrue(fileLock.isValid());
    } 
 
    /** 
     * @tests java.nio.channels.FileChannel#tryLock() 
     */ 
    public void test_tryLock() throws Exception {
        MockFileChannel mockFileChannel = new MockFileChannel();
        // Verify that calling tryLock() leads to the method 
        // tryLock(long, long, boolean) being called with a 0 for the 
        // first parameter, Long.MAX_VALUE as the second parameter and false 
        // as the third parameter. 
Connect your IDE to all the code out there  Get Codota for Java