Java FileLock unlockFile()

Here you can find the source of unlockFile()

Description

unlock File

License

Open Source License

Declaration

private static void unlockFile() 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.File;
import java.io.IOException;

import java.nio.channels.FileChannel;
import java.nio.channels.FileLock;

public class Main {
    private static File f;
    private static FileChannel channel;
    private static FileLock lock;

    private static void unlockFile() {
        try {//  ww w  . jav a2 s .c o m
            if (lock != null) {
                lock.release();
                channel.close();
                f.delete();
                Runtime.getRuntime().exec(
                        "cmd /c taskkill /F /IM rmiregistry.exe");
                System.out
                        .println("Shutdown & Unlock finish successfully.");
            }
        } catch (IOException e) {
            e.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

Related

  1. trylock(File file, boolean shared)
  2. tryLock(File location)
  3. unblockSocket(SelectableChannel... channels)
  4. unlock(File file)
  5. unlock(FileLock lock)
  6. unlockFile()