Code example for FileChannel

Methods: map, read, size

0
	 */ 
	public void map(FileChannel channel, long offset, int baseCapacity) throws IOException {
		flush(); 
		unmap(); 
 
		if (channel.size() >= (offset + ENTRY_OFFSET)) {
			ByteBuffer tmp = ByteBuffer.allocate(8);
			channel.read(tmp, offset);
			this.capacity = tmp.getInt(0);
			this.maxKey = tmp.getInt(4);
		} else { 
			this.capacity = baseCapacity;
			this.maxKey = 0;
		} 
 
		if (capacity <= 0) {
			throw new IllegalArgumentException("Bogus index capacity: " + capacity);
		} 
 
		buffer = channel.map(MapMode.READ_WRITE, offset, ENTRY_OFFSET + (capacity * 8));
		this.offset = offset;
	} 
 
	public void unmap() throws IOException { 
		if (buffer != null) {