Package mgui.io.util
Class EndianCorrectInputStream
java.lang.Object
java.io.InputStream
java.io.FilterInputStream
java.io.DataInputStream
mgui.io.util.EndianCorrectInputStream
- All Implemented Interfaces:
java.io.Closeable,java.io.DataInput,java.lang.AutoCloseable
public class EndianCorrectInputStream
extends java.io.DataInputStream
EndianCorrectInputStream extends DataInputStream; it will optionally flip
bytes to read little endian data correctly.
-
Field Summary
Fields inherited from class java.io.FilterInputStream
in -
Constructor Summary
Constructors Constructor Description EndianCorrectInputStream(java.io.InputStream is, boolean be)Constructor for an InputStream.EndianCorrectInputStream(java.lang.String filename, boolean be)Constructor for a disk file. -
Method Summary
Modifier and Type Method Description doubleflipDouble(double val)flipDouble will flip the byte order of a doublefloatflipFloat(float val)flipFloat will flip the byte order of a floatintflipInt(int val)flipInt will flip the byte order of an intlongflipLong(long val)flipLong will flip the byte order of a longshortflipShort(short val)flipShort will byte flip a shortdoublereadDoubleCorrect()readDoubleCorrect will return a double from the streamfloatreadFloatCorrect()readFloatCorrect will return a float from the streamintreadIntCorrect()readIntCorrect will return an int from the streamlongreadLongCorrect()readLongCorrect will return a long from the streamshortreadShortCorrect()readShortCorrect will return a short from the streamMethods inherited from class java.io.DataInputStream
read, read, readBoolean, readByte, readChar, readDouble, readFloat, readFully, readFully, readInt, readLine, readLong, readShort, readUnsignedByte, readUnsignedShort, readUTF, readUTF, skipBytesMethods inherited from class java.io.FilterInputStream
available, close, mark, markSupported, read, reset, skipMethods inherited from class java.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, skipNBytes, transferToMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
EndianCorrectInputStream
public EndianCorrectInputStream(java.lang.String filename, boolean be) throws java.io.FileNotFoundExceptionConstructor for a disk file.- Parameters:
filename- filename for datafilebe- -- endian flag: if be (big endian) is false bytes will be flipped on read- Throws:
java.io.FileNotFoundException
-
EndianCorrectInputStream
public EndianCorrectInputStream(java.io.InputStream is, boolean be)Constructor for an InputStream.- Parameters:
is- InputStream to read data frombe- -- endian flag: if be (big endian) is false bytes will be flipped on read- Throws:
java.io.FileNotFoundException
-
-
Method Details
-
readShortCorrect
public short readShortCorrect() throws java.io.IOExceptionreadShortCorrect will return a short from the stream- Throws:
java.io.IOException
-
flipShort
public short flipShort(short val)flipShort will byte flip a short -
readIntCorrect
public int readIntCorrect() throws java.io.IOExceptionreadIntCorrect will return an int from the stream- Throws:
java.io.IOException
-
flipInt
public int flipInt(int val)flipInt will flip the byte order of an int -
readLongCorrect
public long readLongCorrect() throws java.io.IOExceptionreadLongCorrect will return a long from the stream- Throws:
java.io.IOException
-
flipLong
public long flipLong(long val)flipLong will flip the byte order of a long -
readFloatCorrect
public float readFloatCorrect() throws java.io.IOExceptionreadFloatCorrect will return a float from the stream- Throws:
java.io.IOException
-
flipFloat
public float flipFloat(float val) throws java.io.IOExceptionflipFloat will flip the byte order of a float- Throws:
java.io.IOException
-
readDoubleCorrect
public double readDoubleCorrect() throws java.io.IOExceptionreadDoubleCorrect will return a double from the stream- Throws:
java.io.IOException
-
flipDouble
public double flipDouble(double val)flipDouble will flip the byte order of a double
-