Table of Contents

Class RandomAccessFileOrArray

Namespace
iText.IO.Source
Assembly
itext.io.dll

Class that is used to unify reading from random access files and arrays.

public class RandomAccessFileOrArray
Inheritance
RandomAccessFileOrArray
Inherited Members

Constructors

RandomAccessFileOrArray(IRandomAccessSource)

Creates a RandomAccessFileOrArray that wraps the specified byte source.

public RandomAccessFileOrArray(IRandomAccessSource byteSource)

Parameters

byteSource IRandomAccessSource

the byte source to wrap

Remarks

Creates a RandomAccessFileOrArray that wraps the specified byte source. The byte source will be closed when this RandomAccessFileOrArray is closed.

Fields

plainRandomAccess

When true the file access is not done through a memory mapped file.

public static bool plainRandomAccess

Field Value

bool

Remarks

When true the file access is not done through a memory mapped file. Use it if the file is too big to be mapped in your address space.

Methods

Close()

Closes the underlying source.

public virtual void Close()

CreateSourceView()

Creates the view of the byte source of this object.

public virtual IRandomAccessSource CreateSourceView()

Returns

IRandomAccessSource

the byte source view.

Remarks

Creates the view of the byte source of this object. Closing the view won't affect this object. Closing source will have adverse effect on the view.

CreateView()

Creates an independent view of this object (with it's own file pointer and push back queue).

public virtual RandomAccessFileOrArray CreateView()

Returns

RandomAccessFileOrArray

the new view

Remarks

Creates an independent view of this object (with it's own file pointer and push back queue). Closing the new object will not close this object. Closing this object will have adverse effect on the view.

GetPosition()

Gets the current position of the source considering the pushed byte to the source.

public virtual long GetPosition()

Returns

long

the index of last read byte in the source in or the index of last read byte in source - 1 in case byte was pushed.

Length()

Gets the total amount of bytes in the source.

public virtual long Length()

Returns

long

source's size.

PushBack(byte)

Pushes a byte back.

public virtual void PushBack(byte b)

Parameters

b byte

the byte to push

Remarks

Pushes a byte back. The next get() will return this byte instead of the value from the underlying data source

Read()

Reads a single byte

public virtual int Read()

Returns

int

the byte, or -1 if EOF is reached

Read(byte[])

Reads the bytes to the buffer.

public virtual int Read(byte[] b)

Parameters

b byte[]

the destination buffer

Returns

int

the number of bytes actually read

Remarks

Reads the bytes to the buffer. This method will try to read as many bytes as the buffer can hold.

Read(byte[], int, int)

Reads the specified amount of bytes to the buffer applying the offset.

public virtual int Read(byte[] b, int off, int len)

Parameters

b byte[]

destination buffer

off int

offset at which to start storing characters

len int

maximum number of characters to read

Returns

int

the number of bytes actually read or -1 in case of EOF

ReadBoolean()

public virtual bool ReadBoolean()

Returns

bool

ReadByte()

public virtual byte ReadByte()

Returns

byte

ReadChar()

public virtual char ReadChar()

Returns

char

ReadCharLE()

Reads a Unicode character from this stream in little-endian order.

public char ReadCharLE()

Returns

char

the next two bytes of this stream as a Unicode character.

Remarks

Reads a Unicode character from this stream in little-endian order. This method reads two bytes from the stream, starting at the current stream pointer. If the bytes read, in order, are b1 and b2 , where 0 <= b1, b2 <= 255 , then the result is equal to:

(char)((b2 << 8) | b1)

This method blocks until the two bytes are read, the end of the stream is detected, or an exception is thrown.

ReadDouble()

public virtual double ReadDouble()

Returns

double

ReadDoubleLE()

public double ReadDoubleLE()

Returns

double

ReadFloat()

public virtual float ReadFloat()

Returns

float

ReadFloatLE()

public float ReadFloatLE()

Returns

float

ReadFully(byte[])

public virtual void ReadFully(byte[] b)

Parameters

b byte[]

ReadFully(byte[], int, int)

public virtual void ReadFully(byte[] b, int off, int len)

Parameters

b byte[]
off int
len int

ReadInt()

public virtual int ReadInt()

Returns

int

ReadIntLE()

Reads a signed 32-bit integer from this stream in little-endian order.

public int ReadIntLE()

Returns

int

the next four bytes of this stream, interpreted as an int.

Remarks

Reads a signed 32-bit integer from this stream in little-endian order. This method reads 4 bytes from the stream, starting at the current stream pointer. If the bytes read, in order, are b1 , b2 , b3 , and b4 , where 0 <= b1, b2, b3, b4 <= 255 , then the result is equal to:

(b4 << 24) | (b3 << 16) + (b2 << 8) + b1

This method blocks until the four bytes are read, the end of the stream is detected, or an exception is thrown.

ReadLine()

public virtual string ReadLine()

Returns

string

ReadLong()

public virtual long ReadLong()

Returns

long

ReadLongLE()

public long ReadLongLE()

Returns

long

ReadShort()

public virtual short ReadShort()

Returns

short

ReadShortLE()

Reads a signed 16-bit number from this stream in little-endian order.

public short ReadShortLE()

Returns

short

the next two bytes of this stream, interpreted as a signed 16-bit number.

Remarks

Reads a signed 16-bit number from this stream in little-endian order. The method reads two bytes from this stream, starting at the current stream pointer. If the two bytes read, in order, are b1 and b2 , where each of the two values is between 0 and 255 , inclusive, then the result is equal to:

(short)((b2 << 8) | b1)

This method blocks until the two bytes are read, the end of the stream is detected, or an exception is thrown.

ReadString(int, string)

Reads a String from the font file as bytes using the given encoding.

public virtual string ReadString(int length, string encoding)

Parameters

length int

the length of bytes to read

encoding string

the given encoding

Returns

string

the String read

ReadUnsignedByte()

public virtual int ReadUnsignedByte()

Returns

int

ReadUnsignedInt()

Reads an unsigned 32-bit integer from this stream.

public long ReadUnsignedInt()

Returns

long

the next four bytes of this stream, interpreted as a long.

Remarks

Reads an unsigned 32-bit integer from this stream. This method reads 4 bytes from the stream, starting at the current stream pointer. If the bytes read, in order, are b1 , b2 , b3 , and b4 , where 0 <= b1, b2, b3, b4 <= 255 , then the result is equal to:

(b1 << 24) | (b2 << 16) + (b3 << 8) + b4

This method blocks until the four bytes are read, the end of the stream is detected, or an exception is thrown.

ReadUnsignedIntLE()

public long ReadUnsignedIntLE()

Returns

long

ReadUnsignedShort()

public virtual int ReadUnsignedShort()

Returns

int

ReadUnsignedShortLE()

Reads an unsigned 16-bit number from this stream in little-endian order.

public int ReadUnsignedShortLE()

Returns

int

the next two bytes of this stream, interpreted as an unsigned 16-bit integer.

Remarks

Reads an unsigned 16-bit number from this stream in little-endian order. This method reads two bytes from the stream, starting at the current stream pointer. If the bytes read, in order, are b1 and b2 , where 0 <= b1, b2 <= 255 , then the result is equal to:

(b2 << 8) | b1

This method blocks until the two bytes are read, the end of the stream is detected, or an exception is thrown.

Seek(long)

Sets the current position in the source to the specified index.

public virtual void Seek(long pos)

Parameters

pos long

the position to set

Skip(long)

Make an attempt to skip the specified amount of bytes in source.

public virtual long Skip(long n)

Parameters

n long

the number of bytes to skip

Returns

long

the actual number of bytes skipped

Remarks

Make an attempt to skip the specified amount of bytes in source. However it may skip less amount of bytes. Possibly zero.

SkipBytes(int)

public virtual int SkipBytes(int n)

Parameters

n int

Returns

int