Package com.itextpdf.text.pdf
Class MappedRandomAccessFile
java.lang.Object
com.itextpdf.text.pdf.MappedRandomAccessFile
A
MappedByteBuffer
wrapped as a RandomAccessFile
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final int
private FileChannel
private MappedByteBuffer[]
private long
private long
-
Constructor Summary
ConstructorsConstructorDescriptionMappedRandomAccessFile
(String filename, String mode) Constructs a new MappedRandomAccessFile instance -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
clean
(ByteBuffer buffer) invokes the clean method on the ByteBuffer's cleanervoid
close()
protected void
finalize()
invokes the close methodlong
private void
init
(FileChannel channel, FileChannel.MapMode mapMode) initializes the channel and mapped bytebufferlong
length()
int
read()
int
read
(byte[] bytes, int off, int len) void
seek
(long pos)
-
Field Details
-
BUFSIZE
private static final int BUFSIZE- See Also:
-
channel
-
mappedBuffers
-
size
private long size -
pos
private long pos
-
-
Constructor Details
-
MappedRandomAccessFile
public MappedRandomAccessFile(String filename, String mode) throws FileNotFoundException, IOException Constructs a new MappedRandomAccessFile instance- Parameters:
filename
- Stringmode
- String r, w or rw- Throws:
FileNotFoundException
IOException
-
-
Method Details
-
init
initializes the channel and mapped bytebuffer- Parameters:
channel
- FileChannelmapMode
- FileChannel.MapMode- Throws:
IOException
-
getChannel
- Since:
- 2.0.8
-
read
public int read()- Returns:
- int next integer or -1 on EOF
- See Also:
-
read
public int read(byte[] bytes, int off, int len) - Parameters:
bytes
- byte[]off
- int offsetlen
- int length- Returns:
- int bytes read or -1 on EOF
- See Also:
-
getFilePointer
public long getFilePointer()- Returns:
- long
- See Also:
-
seek
public void seek(long pos) - Parameters:
pos
- long position- See Also:
-
length
public long length()- Returns:
- long length
- See Also:
-
close
- Throws:
IOException
- See Also:
-
finalize
invokes the close method -
clean
invokes the clean method on the ByteBuffer's cleaner- Parameters:
buffer
- ByteBuffer- Returns:
- boolean true on success
-