Class LittleEndianByteOutputStream

java.lang.Object
java.io.OutputStream
com.webcodepro.shrinkit.io.LittleEndianByteOutputStream
All Implemented Interfaces:
ByteConstants, Closeable, Flushable, AutoCloseable

public class LittleEndianByteOutputStream extends OutputStream implements ByteConstants
An OutputStream with helper methods to write little endian numbers and other Apple-specific tidbits.
  • Constructor Details

    • LittleEndianByteOutputStream

      public LittleEndianByteOutputStream(OutputStream outputStream)
      Construct a LittleEndianByteOutputStream from an OutputStream.
  • Method Details

    • write

      public void write(int b) throws IOException
      Write a next byte.
      Specified by:
      write in class OutputStream
      Throws:
      IOException
    • writeNuFileId

      public void writeNuFileId() throws IOException
      Write the NuFile id to the LittleEndianByteOutputStream.
      Throws:
      IOException
    • writeNuFxId

      public void writeNuFxId() throws IOException
      Write the NuFX id to the LittleEndianByteOutputStream.
      Throws:
      IOException
    • writeWord

      public void writeWord(int w) throws IOException
      Write a "Word".
      Throws:
      IOException
    • writeLong

      public void writeLong(long l) throws IOException
      Write a "Long".
      Throws:
      IOException
    • writeDate

      public void writeDate(Date date) throws IOException
      Write the Java Date object as a TimeRec. Note that years 2000-2039 are assumed to be 00-39 per the NuFX addendum.
      Throws:
      IOException
      See Also:
    • resetCrc

      public void resetCrc()
      Reset the CRC-16 to $0000.
    • getCrcValue

      public long getCrcValue()
      Get the current CRC-16 value.
    • getTotalBytesWritten

      public long getTotalBytesWritten()
      Answer with the total number of bytes written.
    • flush

      public void flush() throws IOException
      Pass the flush request to the wrapped stream.
      Specified by:
      flush in interface Flushable
      Overrides:
      flush in class OutputStream
      Throws:
      IOException
    • close

      public void close() throws IOException
      Pass the close request to the wrapped stream.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Overrides:
      close in class OutputStream
      Throws:
      IOException