Interface IRandomAccessSource
Represents an abstract source that bytes can be read from.
public interface IRandomAccessSource
Remarks
Represents an abstract source that bytes can be read from. This class forms the foundation for all byte input in iText. Implementations do not keep track of a current 'position', but rather provide absolute get methods. Tracking position should be handled in classes that use RandomAccessSource internally (via composition).
Methods
Close()
Closes this source.
void Close()
Remarks
Closes this source. The underlying data structure or source (if any) will also be closed
Get(long)
Gets a byte at the specified position
int Get(long position)
Parameters
position
longbyte position
Returns
- int
the byte, or -1 if EOF is reached
Get(long, byte[], int, int)
Read an array of bytes of specified length from the specified position of source to the buffer applying the offset.
int Get(long position, byte[] bytes, int off, int len)
Parameters
position
longthe position in the RandomAccessSource to read from
bytes
byte[]output buffer
off
intoffset into the output buffer where results will be placed
len
intthe number of bytes to read
Returns
- int
the number of bytes actually read, or -1 if the file is at EOF
Remarks
Read an array of bytes of specified length from the specified position of source to the buffer applying the offset. If the number of bytes requested cannot be read, all the possible bytes will be read to the buffer, and the number of actually read bytes will be returned.
Length()
Gets the length of the source
long Length()
Returns
- long
the length of this source