Code example for FileChannel

Methods: map

0
      int fileNameLength = RandomAccessFileUtility.readPositiveShort(file, offset + LOCNAM);
      int extLength = RandomAccessFileUtility.readPositiveShort(file, offset + LOCEXT);
      FileChannel channel = file.getChannel();
      boolean succeeded = false;
      try { 
        MappedByteBuffer result =
            channel.map(MapMode.READ_ONLY,
                        offset + LOCHDR + fileNameLength + extLength, size);
        succeeded = true;
        return result;
      } finally { 
        // MappedByteBuffer is valid even after back-end Channel and/or RandomAccessFile 
        // is/are closed (documented spec). 
        MozcUtil.close(channel, !succeeded);
      } 
    } 
  } 
 
  /** 
   * Gets a {@link ByteBuffer} to the entry's content. 
   *