Package java.nio.channels

Examples of java.nio.channels.FileLock.release()


        // release after release
        fout = new FileOutputStream(file);
        fileChannel = fout.getChannel();
        fileLock = fileChannel.lock();
        fileLock.release();
        fileChannel.close();
        try {
            fileLock.release();
            fail("should throw ClosedChannelException");
        } catch (ClosedChannelException e) {
View Full Code Here


        fileChannel = fout.getChannel();
        fileLock = fileChannel.lock();
        fileLock.release();
        fileChannel.close();
        try {
            fileLock.release();
            fail("should throw ClosedChannelException");
        } catch (ClosedChannelException e) {
            //expected
        }
    }
View Full Code Here

    public void test_lockReadWrite() throws IOException {
        // Acquire an exclusive lock across the entire file.
        FileLock flock = readWriteChannel.lock();
        if (flock != null) {
            flock.release();
        }
    }

    public void test_illegalLockParameters() throws IOException {
        // Cannot lock negative positions
View Full Code Here

        // Try to acquire an overlapping lock.
        try {
            readWriteChannel.lock(75, 210, true);
        } catch (OverlappingFileLockException exception) {
            // expected
            flock1.release();
        }
    }

    public void test_lockLLZ() throws IOException {
        // Lock a range at the front, non-shared.
View Full Code Here

        // Lock a shared range further in the same file.
        FileLock flock2 = readWriteChannel.lock(22, 100, true);

        // The spec allows the impl to refuse shared locks
        flock1.release();
        flock2.release();
    }

    public void test_tryLock() throws IOException {
        try {
            readOnlyChannel.tryLock();
View Full Code Here

        }

        // Acquire a valid lock
        FileLock tmpLock = readOnlyChannel.tryLock(0, 10, true);
        assertTrue(tmpLock.isValid());
        tmpLock.release();

        // Acquire another valid lock -- and don't release it yet
        FileLock lock = readOnlyChannel.tryLock(10, 788, true);
        assertTrue(lock.isValid());
View Full Code Here

        }

        // Adjacent locks are legal
        FileLock adjacentLock = readOnlyChannel.tryLock(1, 3, true);
        assertTrue(adjacentLock.isValid());
        adjacentLock.release();

        // Release longer lived lock
        lock.release();
    }
}
View Full Code Here

            PrintWriter writer = new PrintWriter(out, false);
            writer.println(DATE_FORMAT.format(date)+" - "+action+" - "+username);
            writer.flush();
            writer.close();
            if(lock.isValid()) {
                lock.release();
            }
        } catch (IOException e) {
            throw new RuntimeException("Unable to write to authentication log file", e);
        }
    }
View Full Code Here

            PrintWriter writer = new PrintWriter(out, false);
            writer.println(DATE_FORMAT.format(date)+" - "+action+" - "+username);
            writer.flush();
            writer.close();
            if(lock.isValid()) {
                lock.release();
            }
        } catch (IOException e) {
            throw new RuntimeException("Unable to write to authentication log file", e);
        }
    }
View Full Code Here

               
                bytesRead = is.read(bb.array());
            }
        } finally {
            // Release the lock
           lock.release();
           releaseTempByteBuffer(bb);
        }
        return true;
    }
   
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.