Class ObjectEndianInputStream
- java.lang.Object
-
- nl.tudelft.simulation.dsol.animation.gis.io.ObjectEndianInputStream
-
- All Implemented Interfaces:
DataInput
public class ObjectEndianInputStream extends Object implements DataInput
This class enables the object inputstream to be switched from big endian (default in Java) to little endian. The class works exactly like an ObjectInputStream.Copyright (c) 2020-2023 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information DSOL Manual. The DSOL project is distributed under a three-clause BSD-style license, which can be found at DSOL License.
- Author:
- Alexander Verbraeck
-
-
Constructor Summary
Constructors Constructor Description ObjectEndianInputStream(InputStream inputStream)constructs a new ObjectEndianInputStream.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()EndiannessgetEndianness()Return the Endianness, i.e., big endian or little endian encoding.intread(byte[] b)reads b from the stream.intread(byte[] b, int off, int len)reads b from the stream.booleanreadBoolean()bytereadByte()charreadChar()doublereadDouble()floatreadFloat()voidreadFully(byte[] b)voidreadFully(byte[] b, int off, int len)intreadInt()StringreadLine()longreadLong()shortreadShort()intreadUnsignedByte()intreadUnsignedShort()StringreadUTF()static StringreadUTF(DataInput dataInput)reads UTF from the stream.voidsetEndianness(Endianness endianness)Set the Endianness, i.e., big endian or little endian encoding.intskipBytes(int n)
-
-
-
Constructor Detail
-
ObjectEndianInputStream
public ObjectEndianInputStream(InputStream inputStream)
constructs a new ObjectEndianInputStream.- Parameters:
inputStream- InputStream; the inputStream to use
-
-
Method Detail
-
readShort
public short readShort() throws IOException- Specified by:
readShortin interfaceDataInput- Throws:
IOException
-
readUnsignedShort
public int readUnsignedShort() throws IOException- Specified by:
readUnsignedShortin interfaceDataInput- Throws:
IOException
-
readChar
public char readChar() throws IOException- Specified by:
readCharin interfaceDataInput- Throws:
IOException
-
readInt
public int readInt() throws IOException- Specified by:
readIntin interfaceDataInput- Throws:
IOException
-
readLong
public long readLong() throws IOException- Specified by:
readLongin interfaceDataInput- Throws:
IOException
-
readFloat
public float readFloat() throws IOException- Specified by:
readFloatin interfaceDataInput- Throws:
IOException
-
readDouble
public double readDouble() throws IOException- Specified by:
readDoublein interfaceDataInput- Throws:
IOException
-
read
public int read(byte[] b) throws IOExceptionreads b from the stream.- Parameters:
b- byte[]; byte- Returns:
- in the value
- Throws:
IOException- on failure
-
read
public int read(byte[] b, int off, int len) throws IOExceptionreads b from the stream.- Parameters:
b- byte[]; byteoff- int; offsetlen- int; length- Returns:
- in the value
- Throws:
IOException- on failure
-
readFully
public void readFully(byte[] b) throws IOException- Specified by:
readFullyin interfaceDataInput- Throws:
IOException
-
readFully
public void readFully(byte[] b, int off, int len) throws IOException- Specified by:
readFullyin interfaceDataInput- Throws:
IOException
-
skipBytes
public int skipBytes(int n) throws IOException- Specified by:
skipBytesin interfaceDataInput- Throws:
IOException
-
readBoolean
public boolean readBoolean() throws IOException- Specified by:
readBooleanin interfaceDataInput- Throws:
IOException
-
readByte
public byte readByte() throws IOException- Specified by:
readBytein interfaceDataInput- Throws:
IOException
-
readUnsignedByte
public int readUnsignedByte() throws IOException- Specified by:
readUnsignedBytein interfaceDataInput- Throws:
IOException
-
readUTF
public String readUTF() throws IOException
- Specified by:
readUTFin interfaceDataInput- Throws:
IOException
-
readUTF
public static final String readUTF(DataInput dataInput) throws IOException
reads UTF from the stream.- Parameters:
dataInput- DataInput; data input- Returns:
- String the value
- Throws:
IOException- on read failure
-
close
public void close() throws IOException- Throws:
IOException- on close failure
-
getEndianness
public Endianness getEndianness()
Return the Endianness, i.e., big endian or little endian encoding.- Returns:
- Endianness; big endian or little endian encoding
-
setEndianness
public void setEndianness(Endianness endianness)
Set the Endianness, i.e., big endian or little endian encoding.- Parameters:
endianness- Endianness; big endian or little endian encoding
-
-