Package mgui.io.util

Class EndianCorrectOutputStream

java.lang.Object
java.io.OutputStream
java.io.FilterOutputStream
java.io.DataOutputStream
mgui.io.util.EndianCorrectOutputStream
All Implemented Interfaces:
java.io.Closeable, java.io.DataOutput, java.io.Flushable, java.lang.AutoCloseable

public class EndianCorrectOutputStream
extends java.io.DataOutputStream
EndianCorrectOutputStream extends DataOutputStream; it will optionally flip bytes to write little endian data correctly.
  • Field Summary

    Fields inherited from class java.io.DataOutputStream

    written

    Fields inherited from class java.io.FilterOutputStream

    out
  • Constructor Summary

    Constructors
    Constructor Description
    EndianCorrectOutputStream​(java.io.OutputStream os, boolean be)
    Constructor for an OutputStream.
    EndianCorrectOutputStream​(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
    void writeDoubleCorrect​(double val)
    writeDoubleCorrect will write a double to the stream
    void writeFloatCorrect​(float val)
    writeFloatCorrect will write a float to the stream
    void writeIntCorrect​(int val)
    writeIntCorrect will write an int to the stream
    void writeLongCorrect​(long val)
    writeLongCorrect will write a long to the stream
    void writeShortCorrect​(short val)
    writeShortCorrect will write a short to the stream

    Methods inherited from class java.io.DataOutputStream

    flush, size, write, write, writeBoolean, writeByte, writeBytes, writeChar, writeChars, writeDouble, writeFloat, writeInt, writeLong, writeShort, writeUTF

    Methods inherited from class java.io.FilterOutputStream

    close, write

    Methods inherited from class java.io.OutputStream

    nullOutputStream

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface java.io.DataOutput

    write
  • Constructor Details

    • EndianCorrectOutputStream

      public EndianCorrectOutputStream​(java.lang.String filename, boolean be) throws java.io.FileNotFoundException, java.lang.SecurityException
      Constructor for a disk file.
      Parameters:
      filename - filename for datafile
      be - -- endian flag: if be (big endian) is false bytes will be flipped on write
      Throws:
      java.io.FileNotFoundException
      java.lang.SecurityException
    • EndianCorrectOutputStream

      public EndianCorrectOutputStream​(java.io.OutputStream os, boolean be)
      Constructor for an OutputStream.
      Parameters:
      is - OutputStream to write data to
      be - -- endian flag: if be (big endian) is false bytes will be flipped on write
      Throws:
      java.io.FileNotFoundException
  • Method Details

    • writeShortCorrect

      public void writeShortCorrect​(short val) throws java.io.IOException
      writeShortCorrect will write a short to the stream
      Throws:
      java.io.IOException
    • flipShort

      public short flipShort​(short val)
      flipShort will byte flip a short
    • writeIntCorrect

      public void writeIntCorrect​(int val) throws java.io.IOException
      writeIntCorrect will write an int to the stream
      Throws:
      java.io.IOException
    • flipInt

      public int flipInt​(int val)
      flipInt will flip the byte order of an int
    • writeLongCorrect

      public void writeLongCorrect​(long val) throws java.io.IOException
      writeLongCorrect will write a long to the stream
      Throws:
      java.io.IOException
    • flipLong

      public long flipLong​(long val)
      flipLong will flip the byte order of a long
    • writeFloatCorrect

      public void writeFloatCorrect​(float val) throws java.io.IOException
      writeFloatCorrect will write a float to 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
    • writeDoubleCorrect

      public void writeDoubleCorrect​(double val) throws java.io.IOException
      writeDoubleCorrect will write a double to the stream
      Throws:
      java.io.IOException
    • flipDouble

      public double flipDouble​(double val)
      flipDouble will flip the byte order of a double