Code example for FileChannel

Methods: lockread

0
      FileLock lock = null;
      try { 
        mBuffer.clear();
        mBuffer.limit(1 + 8);
 
        lock = mChannel.lock(pos, 1 + 8, true);
        if (mChannel.read(mBuffer, pos) == 9) {
          mBuffer.position(0);
          if (mBuffer.get() == 1)
            return mBuffer.getLong();
        } 
      } catch (IOException ex) {
      } catch (RuntimeException ex) {
      } finally { 
        try { 
          if (lock != null)
            lock.release();
        } catch (IOException ex) {
        } 
      } 
Contextual code suggestions in your IDE  Get Codota for Java