Class MappedRandomAccessFile
java.lang.Object
org.openpdf.text.pdf.MappedRandomAccessFile
- All Implemented Interfaces:
AutoCloseable
A
MappedByteBuffer wrapped as a RandomAccessFile-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionMappedRandomAccessFile(String filename, String mode) Constructs a new MappedRandomAccessFile instance -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Cleans the mapped bytebuffer and closes the channellongprivate voidinit(FileChannel channel, FileChannel.MapMode mapMode) initializes the channel and mapped bytebufferlonglength()intread()intread(byte[] bytes, int off, int len) voidseek(long pos)
-
Field Details
-
mappedByteBuffer
-
channel
-
-
Constructor Details
-
MappedRandomAccessFile
Constructs a new MappedRandomAccessFile instance- Parameters:
filename- Stringmode- String r, w or rw- Throws:
FileNotFoundException- on errorIOException- on error
-
-
Method Details
-
init
initializes the channel and mapped bytebuffer- Parameters:
channel- FileChannelmapMode- FileChannel.MapMode- Throws:
IOException
-
getChannel
- Returns:
- FileChannel
- Since:
- 2.0.8
-
read
public int read()- Returns:
- int next byte value 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
Cleans the mapped bytebuffer and closes the channel- Specified by:
closein interfaceAutoCloseable- Throws:
IOException- on error- See Also:
-