Code example for FileLock

Methods: isValidrelease

0
            FileLock lock = channel.lock(0, Long.MAX_VALUE, false);
            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);
        } 
    } 
 
    public boolean commit() throws LoginException {
        if(username != null) {
            writeToFile("Authentication succeeded"); 
        } 
        return false; 
    } 
 
Contextual code suggestions in your IDE  Get Codota for Java