Class LittleEndianOutputStream

  • All Implemented Interfaces:
    java.io.Closeable, java.io.Flushable, java.lang.AutoCloseable
    Direct Known Subclasses:
    WasmOutputStream

    public class LittleEndianOutputStream
    extends java.io.FilterOutputStream
    outputStream with little endian encoding like in Wasm.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private int count  
      • Fields inherited from class java.io.FilterOutputStream

        out
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void reset()
      Reset the stream.
      int size()
      The count of bytes in the stream.
      void write​(byte[] b, int off, int len)
      void write​(int b)
      void writeInt32​(int value)
      Write a integer little endian (ever 4 bytes)
      void writeTo​(java.io.OutputStream output)
      Write the data of this stream to the output.
      • Methods inherited from class java.io.FilterOutputStream

        close, flush, 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
    • Field Detail

      • count

        private int count
    • Constructor Detail

      • LittleEndianOutputStream

        public LittleEndianOutputStream()
        Create a in memory stream.
      • LittleEndianOutputStream

        public LittleEndianOutputStream​(java.io.OutputStream output)
        Create a wrapped stream.
        Parameters:
        output - the target of data
    • Method Detail

      • write

        public void write​(int b)
                   throws java.io.IOException
        Overrides:
        write in class java.io.FilterOutputStream
        Throws:
        java.io.IOException
      • write

        public void write​(byte[] b,
                          int off,
                          int len)
                   throws java.io.IOException
        Overrides:
        write in class java.io.FilterOutputStream
        Throws:
        java.io.IOException
      • writeInt32

        public void writeInt32​(int value)
                        throws java.io.IOException
        Write a integer little endian (ever 4 bytes)
        Parameters:
        value - the value
        Throws:
        java.io.IOException - if an I/O error occurs.
      • writeTo

        public void writeTo​(java.io.OutputStream output)
                     throws java.io.IOException
        Write the data of this stream to the output. Work only for in memory stream.
        Parameters:
        output - the target
        Throws:
        java.io.IOException - if any I/O error occur
      • size

        public int size()
        The count of bytes in the stream.
        Returns:
        the data size
      • reset

        public void reset()
        Reset the stream. Work only for in memory stream.