Class BinaryIO

java.lang.Object
gov.usgs.earthquake.product.io.BinaryIO

public class BinaryIO extends Object
Class to read and write Binary streams
  • Constructor Details

    • BinaryIO

      public BinaryIO()
  • Method Details

    • writeInt

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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