Code example for FileLock

Methods: isValidrelease

0
	/** 
	 * @tests java.nio.channels.FileLock#isValid() 
	 */ 
	public void test_isValid() throws IOException {
		FileLock fileLock = readWriteChannel.lock();
		assertTrue(fileLock.isValid());
		fileLock.release();
		assertFalse(fileLock.isValid());
	} 
     
    /** 
     * @tests java.nio.channels.FileLock#release() 
     */ 
    public void test_release() throws Exception {
        File file = File.createTempFile("test", "tmp");
        file.deleteOnExit();
        FileOutputStream fout = new FileOutputStream(file);
        FileChannel fileChannel = fout.getChannel();
        FileLock fileLock = fileChannel.lock();
        fileChannel.close();
Experience pair programming with AI  Get Codota for Java