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
    double flipDouble​(double val)
    flipDouble will flip the byte order of a double
    float flipFloat​(float val)
    flipFloat will flip the byte order of a float
    int flipInt​(int val)
    flipInt will flip the byte order of an int
    long flipLong​(long val)
    flipLong will flip the byte order of a long
    short flipShort​(short val)
    flipShort will byte flip a short
    double readDoubleCorrect()
    readDoubleCorrect will return a double from the stream
    float readFloatCorrect()
    readFloatCorrect will return a float from the stream
    int readIntCorrect()
    readIntCorrect will return an int from the stream
    long readLongCorrect()
    readLongCorrect will return a long from the stream
    short readShortCorrect()
    readShortCorrect will return a short from the stream

    Methods inherited from class java.io.DataInputStream

    read, read, readBoolean, readByte, readChar, readDouble, readFloat, readFully, readFully, readInt, readLine, readLong, readShort, readUnsignedByte, readUnsignedShort, readUTF, readUTF, skipBytes

    Methods inherited from class java.io.FilterInputStream

    available, close, mark, markSupported, read, reset, skip

    Methods inherited from class java.io.InputStream

    nullInputStream, readAllBytes, readNBytes, readNBytes, skipNBytes, transferTo

    Methods 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.FileNotFoundException
      Constructor for a disk file.
      Parameters:
      filename - filename for datafile
      be - -- 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 from
      be - -- 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.IOException
      readShortCorrect 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.IOException
      readIntCorrect 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.IOException
      readLongCorrect 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.IOException
      readFloatCorrect will return a float from the stream
      Throws:
      java.io.IOException
    • flipFloat

      public float flipFloat​(float val) throws java.io.IOException
      flipFloat will flip the byte order of a float
      Throws:
      java.io.IOException
    • readDoubleCorrect

      public double readDoubleCorrect() throws java.io.IOException
      readDoubleCorrect 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