Code example for FileChannel

Methods: tryLock

0
        trace("lockImpl(): fl = fc.tryLock()"); 
 
        fl = null;
 
        try { 
            fl = fc.tryLock(0, MIN_LOCK_REGION, false);
 
            trace("lockImpl(): fl = " + fl);
        } catch (Exception e) {
 
            // This will not work with a localized JVM 
            /* 
            if (-1 == e.toString().indexOf("No locks available")) { 
                throw e; 
            } else { 
                trace(e.toString()); 
            } 
            */ 
            trace(e.toString());
        }