public class FileChannelRandomAccessSource extends Object implements IRandomAccessSource
FileChannel.
The entire channel will be mapped into memory for efficient reads.| Constructor and Description |
|---|
FileChannelRandomAccessSource(FileChannel channel)
Constructs a new
FileChannelRandomAccessSource based on the specified FileChannel. |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes this source.
|
int |
get(long position)
Gets a byte at the specified position
|
int |
get(long position,
byte[] bytes,
int off,
int len)
Read an array of bytes of specified length from the specified position of source to the buffer applying the offset.
|
long |
length()
Gets the length of the source
|
public FileChannelRandomAccessSource(FileChannel channel) throws IOException
FileChannelRandomAccessSource based on the specified FileChannel. The entire source channel will be mapped into memory.channel - the channel to use as the backing storeIOException - if the channel cannot be opened or mappedpublic void close()
throws IOException
close in interface IRandomAccessSourceIOException - in case of any reading error.public int get(long position)
throws IOException
get in interface IRandomAccessSourceposition - byte positionIOException - in case of any reading error.public int get(long position,
byte[] bytes,
int off,
int len)
throws IOException
get in interface IRandomAccessSourceposition - the position in the RandomAccessSource to read frombytes - output bufferoff - offset into the output buffer where results will be placedlen - the number of bytes to readIOException - in case of any I/O error.public long length()
length in interface IRandomAccessSourceCopyright © 1998–2023 iText Group NV. All rights reserved.