Code example for FileChannel

Methods: truncate

0
        return success;
    } 
 
    public void release() throws IOException { 
        if (this.hasLock()) {
            channel.truncate(0);
            lock.release();
            lock = null;
        } 
    } 
 
    public boolean hasLock() { 
        boolean locked = false;
        if ((lock != null) && (lock.isValid())) {
            locked = true;
        } 
        return locked;
    } 
}