Package com.ardor3d.util
Class LittleEndianRandomAccessDataInput
java.lang.Object
com.ardor3d.util.LittleEndianRandomAccessDataInput
- All Implemented Interfaces:
DataInput
Utility class useful for reading little-endian stored data in a random access fashion. All functions work as defined
in DataInput, but assume they come from a LittleEndian input stream.
Note: random access is implemented by reading the entire stream into memory.
-
Field Summary
-
Constructor Summary
ConstructorDescriptionCreates a new LittleEndian reader from the given input stream.LittleEndianRandomAccessDataInput
(ByteBuffer contents) Creates a new LittleEndian reader from the given byte buffer. -
Method Summary
Modifier and TypeMethodDescriptionint
capacity()
mark()
Sets a mark at the current position in the underlying buffer.int
position()
final boolean
final byte
readByte()
final char
readChar()
final double
final float
final void
readFully
(byte[] b) final void
readFully
(byte[] b, int off, int len) final int
readInt()
final String
readLine()
Unsupported.final long
readLong()
final short
readString
(int size) Reads a specified number of bytes to form a string.readString
(int size, Charset charset) Reads a specified number of bytes to form a string.final int
final long
final int
final String
readUTF()
Unsupported.reset()
Seeks to the position of the last mark.final void
seek
(int pos) final int
skipBytes
(int n)
-
Field Details
-
CHAR_SIZE
public int CHAR_SIZENumber of bytes to read when reading a char... For data meant to be read from C/C++ this is often 1, for Java and C# this is usually 2.
-
-
Constructor Details
-
LittleEndianRandomAccessDataInput
Creates a new LittleEndian reader from the given input stream. Note that this stream is loaded completely into memory.- Parameters:
in
- The stream to read from.- Throws:
IOException
- if something wrong occurs while reading
-
LittleEndianRandomAccessDataInput
Creates a new LittleEndian reader from the given byte buffer. Note that this byte buffer is not cloned or copied, so take care not to alter it during read. This constructor is useful for working with memory-mapped files.- Parameters:
contents
- The contents to read from.- Throws:
IOException
- if something wrong occurs while reading
-
-
Method Details
-
readUnsignedShort
- Specified by:
readUnsignedShort
in interfaceDataInput
- Throws:
IOException
-
readUnsignedInt
- Throws:
IOException
-
readBoolean
- Specified by:
readBoolean
in interfaceDataInput
- Throws:
IOException
-
readByte
- Specified by:
readByte
in interfaceDataInput
- Throws:
IOException
-
readUnsignedByte
- Specified by:
readUnsignedByte
in interfaceDataInput
- Throws:
IOException
-
readShort
- Specified by:
readShort
in interfaceDataInput
- Throws:
IOException
-
readChar
- Specified by:
readChar
in interfaceDataInput
- Throws:
IOException
-
readInt
- Specified by:
readInt
in interfaceDataInput
- Throws:
IOException
-
readLong
- Specified by:
readLong
in interfaceDataInput
- Throws:
IOException
-
readFloat
- Specified by:
readFloat
in interfaceDataInput
- Throws:
IOException
-
readDouble
- Specified by:
readDouble
in interfaceDataInput
- Throws:
IOException
-
readFully
- Specified by:
readFully
in interfaceDataInput
- Throws:
IOException
-
readFully
- Specified by:
readFully
in interfaceDataInput
- Throws:
IOException
-
skipBytes
- Specified by:
skipBytes
in interfaceDataInput
- Throws:
IOException
-
mark
Sets a mark at the current position in the underlying buffer. This position can be returned to by calling reset.- Returns:
- this object
-
reset
Seeks to the position of the last mark. The mark is not changed or discarded.- Returns:
- this object
- Throws:
InvalidMarkException
- if mark was not previously called.
-
readLine
Unsupported.- Specified by:
readLine
in interfaceDataInput
- Throws:
IOException
- if this method is called.
-
readUTF
Unsupported.- Specified by:
readUTF
in interfaceDataInput
- Throws:
IOException
- if this method is called.
-
readString
Reads a specified number of bytes to form a string. The length of the string (number of characters) is required to notify when reading should stop. The index is increased the number of characters read.- Parameters:
size
- the length of the string to read.charset
- the charset used to convert the bytes to a string.- Returns:
- the string read.
- Throws:
IOException
- if EOS/EOF is reached before "size" number of bytes are read.
-
readString
Reads a specified number of bytes to form a string. The length of the string (number of characters) is required to notify when reading should stop. The index is increased the number of characters read. Will use the platform's default Charset to convert the bytes to string.- Parameters:
size
- the length of the string to read.- Returns:
- the string read.
- Throws:
IOException
- if EOS/EOF is reached before "size" number of bytes are read.
-
seek
- Throws:
IOException
-
position
public int position() -
capacity
public int capacity()
-