Class BinaryIO


  • public class BinaryIO
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      BinaryIO()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      byte[] readBytes​(java.io.InputStream in)
      Reads a byte array from the InputStream
      java.util.Date readDate​(java.io.InputStream in)
      Reads date from the InputStream
      protected void readFully​(byte[] buffer, java.io.InputStream in)
      Function used by other read funcs Reads from input stream until buffer is full
      int readInt​(java.io.InputStream in)
      Reads 4 bytes from the InputStream
      long readLong​(java.io.InputStream in)
      Reads 8 bytes from the InputStream
      void readStream​(long length, java.io.InputStream in, java.io.OutputStream out)
      Function called by previous readStream Used to read whole stream
      void readStream​(java.io.InputStream in, java.io.OutputStream out)
      Reads stream
      java.lang.String readString​(java.io.InputStream in)
      Reads string from the InputStream
      java.lang.String readString​(java.io.InputStream in, int maxLength)
      Reads string with a max length from the InputStream
      void writeBytes​(byte[] toWrite, java.io.OutputStream out)
      Writes an array of bytes to the OutputStream buffer
      void writeDate​(java.util.Date toWrite, java.io.OutputStream out)
      Writes a date to the OutputStream buffer
      void writeInt​(int in, java.io.OutputStream out)
      Writes an int to the OutputStream buffer
      void writeLong​(long in, java.io.OutputStream out)
      Writes an long to the OutputStream buffer
      void writeStream​(long length, java.io.InputStream in, java.io.OutputStream out)
      Writes a long to the OutputStream buffer
      void writeString​(java.lang.String toWrite, java.io.OutputStream out)
      Writes a string to the OutputStream buffer
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • BinaryIO

        public BinaryIO()
    • Method Detail

      • writeInt

        public void writeInt​(int in,
                             java.io.OutputStream out)
                      throws java.io.IOException
        Writes an int to the OutputStream buffer
        Parameters:
        in - an int to write
        out - the OutputStream
        Throws:
        java.io.IOException - if IO error occurs
      • writeLong

        public void writeLong​(long in,
                              java.io.OutputStream out)
                       throws java.io.IOException
        Writes an long to the OutputStream buffer
        Parameters:
        in - an long to write
        out - the OutputStream
        Throws:
        java.io.IOException - if IO error occurs
      • writeBytes

        public void writeBytes​(byte[] toWrite,
                               java.io.OutputStream out)
                        throws java.io.IOException
        Writes an array of bytes to the OutputStream buffer
        Parameters:
        toWrite - an array of bytes to write
        out - the OutputStream
        Throws:
        java.io.IOException - if IO error occurs
      • writeString

        public void writeString​(java.lang.String toWrite,
                                java.io.OutputStream out)
                         throws java.io.IOException
        Writes a string to the OutputStream buffer
        Parameters:
        toWrite - a string to write
        out - the OutputStream
        Throws:
        java.io.IOException - if IO error occurs
      • writeDate

        public void writeDate​(java.util.Date toWrite,
                              java.io.OutputStream out)
                       throws java.io.IOException
        Writes a date to the OutputStream buffer
        Parameters:
        toWrite - a date to write
        out - the OutputStream
        Throws:
        java.io.IOException - if IO error occurs
      • writeStream

        public void writeStream​(long length,
                                java.io.InputStream in,
                                java.io.OutputStream out)
                         throws java.io.IOException
        Writes a long to the OutputStream buffer
        Parameters:
        length - a long to write
        in - an input stream
        out - the OutputStream
        Throws:
        java.io.IOException - if IO error occurs
      • readInt

        public int readInt​(java.io.InputStream in)
                    throws java.io.IOException
        Reads 4 bytes from the InputStream
        Parameters:
        in - InputStream
        Returns:
        an int
        Throws:
        java.io.IOException - if IO Error occurs
      • readLong

        public long readLong​(java.io.InputStream in)
                      throws java.io.IOException
        Reads 8 bytes from the InputStream
        Parameters:
        in - InputStream
        Returns:
        a long
        Throws:
        java.io.IOException - if IO Error occurs
      • readBytes

        public byte[] readBytes​(java.io.InputStream in)
                         throws java.io.IOException
        Reads a byte array from the InputStream
        Parameters:
        in - InputStream
        Returns:
        Byte[]
        Throws:
        java.io.IOException - if IO Error occurs
      • readString

        public java.lang.String readString​(java.io.InputStream in)
                                    throws java.io.IOException
        Reads string from the InputStream
        Parameters:
        in - InputStream
        Returns:
        a string
        Throws:
        java.io.IOException - if IO Error occurs
      • readString

        public java.lang.String readString​(java.io.InputStream in,
                                           int maxLength)
                                    throws java.io.IOException
        Reads string with a max length from the InputStream
        Parameters:
        in - InputStream
        maxLength - of string
        Returns:
        an string
        Throws:
        java.io.IOException - if IO Error occurs
      • readDate

        public java.util.Date readDate​(java.io.InputStream in)
                                throws java.io.IOException
        Reads date from the InputStream
        Parameters:
        in - InputStream
        Returns:
        a date
        Throws:
        java.io.IOException - if IO Error occurs
      • readStream

        public void readStream​(java.io.InputStream in,
                               java.io.OutputStream out)
                        throws java.io.IOException
        Reads stream
        Parameters:
        in - InputStream
        out - OutputStream
        Throws:
        java.io.IOException - if IO Error occurs
      • readStream

        public void readStream​(long length,
                               java.io.InputStream in,
                               java.io.OutputStream out)
                        throws java.io.IOException
        Function called by previous readStream Used to read whole stream
        Parameters:
        length - length of inputstream
        in - input stream
        out - output stream
        Throws:
        java.io.IOException - if io error occurs
      • readFully

        protected void readFully​(byte[] buffer,
                                 java.io.InputStream in)
                          throws java.io.IOException
        Function used by other read funcs Reads from input stream until buffer is full
        Parameters:
        buffer - byte[]
        in - inputstream
        Throws:
        java.io.IOException - if IO error occurs