com.lowagie.text.pdf

Class MappedRandomAccessFile

public class MappedRandomAccessFile extends Object

A java.nio.MappedByteBuffer wrapped as a java.io.RandomAccessFile

Author: Joakim Sandstroem Created on 6.9.2006

Field Summary
FileChannelchannel
MappedByteBuffermappedByteBuffer
Constructor Summary
MappedRandomAccessFile(String filename, String mode)
Constructs a new MappedRandomAccessFile instance
Method Summary
static booleanclean(ByteBuffer buffer)
invokes the clean method on the ByteBuffer's cleaner
voidclose()
protected voidfinalize()
invokes the close method
FileChannelgetChannel()
longgetFilePointer()
voidinit(FileChannel channel, MapMode mapMode)
initializes the channel and mapped bytebuffer
longlength()
intread()
intread(byte[] bytes, int off, int len)
voidseek(long pos)

Field Detail

channel

private FileChannel channel

mappedByteBuffer

private MappedByteBuffer mappedByteBuffer

Constructor Detail

MappedRandomAccessFile

public MappedRandomAccessFile(String filename, String mode)
Constructs a new MappedRandomAccessFile instance

Parameters: filename String mode String r, w or rw

Throws: FileNotFoundException IOException

Method Detail

clean

public static boolean clean(ByteBuffer buffer)
invokes the clean method on the ByteBuffer's cleaner

Parameters: buffer ByteBuffer

Returns: boolean true on success

close

public void close()

See Also: java.io.RandomAccessFile#close() Cleans the mapped bytebuffer and closes the channel

finalize

protected void finalize()
invokes the close method

See Also: java.lang.Object#finalize()

getChannel

public FileChannel getChannel()

Since: 2.0.8

getFilePointer

public long getFilePointer()

Returns: long

See Also: java.io.RandomAccessFile#getFilePointer()

init

private void init(FileChannel channel, MapMode mapMode)
initializes the channel and mapped bytebuffer

Parameters: channel FileChannel mapMode FileChannel.MapMode

Throws: IOException

length

public long length()

Returns: long length

See Also: java.io.RandomAccessFile#length()

read

public int read()

Returns: int next integer or -1 on EOF

See Also: java.io.RandomAccessFile#read()

read

public int read(byte[] bytes, int off, int len)

Parameters: bytes byte[] off int offset len int length

Returns: int bytes read or -1 on EOF

See Also: java.io.RandomAccessFile#read(byte[], int, int)

seek

public void seek(long pos)

Parameters: pos long position

See Also: java.io.RandomAccessFile#seek(long)