Package gov.usgs.earthquake.product.io
Class BinaryIO
- java.lang.Object
-
- gov.usgs.earthquake.product.io.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 InputStreamjava.util.DatereadDate(java.io.InputStream in)Reads date from the InputStreamprotected voidreadFully(byte[] buffer, java.io.InputStream in)Function used by other read funcs Reads from input stream until buffer is fullintreadInt(java.io.InputStream in)Reads 4 bytes from the InputStreamlongreadLong(java.io.InputStream in)Reads 8 bytes from the InputStreamvoidreadStream(long length, java.io.InputStream in, java.io.OutputStream out)Function called by previous readStream Used to read whole streamvoidreadStream(java.io.InputStream in, java.io.OutputStream out)Reads streamjava.lang.StringreadString(java.io.InputStream in)Reads string from the InputStreamjava.lang.StringreadString(java.io.InputStream in, int maxLength)Reads string with a max length from the InputStreamvoidwriteBytes(byte[] toWrite, java.io.OutputStream out)Writes an array of bytes to the OutputStream buffervoidwriteDate(java.util.Date toWrite, java.io.OutputStream out)Writes a date to the OutputStream buffervoidwriteInt(int in, java.io.OutputStream out)Writes an int to the OutputStream buffervoidwriteLong(long in, java.io.OutputStream out)Writes an long to the OutputStream buffervoidwriteStream(long length, java.io.InputStream in, java.io.OutputStream out)Writes a long to the OutputStream buffervoidwriteString(java.lang.String toWrite, java.io.OutputStream out)Writes a string to the OutputStream buffer
-
-
-
Method Detail
-
writeInt
public void writeInt(int in, java.io.OutputStream out) throws java.io.IOExceptionWrites an int to the OutputStream buffer- Parameters:
in- an int to writeout- the OutputStream- Throws:
java.io.IOException- if IO error occurs
-
writeLong
public void writeLong(long in, java.io.OutputStream out) throws java.io.IOExceptionWrites an long to the OutputStream buffer- Parameters:
in- an long to writeout- the OutputStream- Throws:
java.io.IOException- if IO error occurs
-
writeBytes
public void writeBytes(byte[] toWrite, java.io.OutputStream out) throws java.io.IOExceptionWrites an array of bytes to the OutputStream buffer- Parameters:
toWrite- an array of bytes to writeout- 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.IOExceptionWrites a string to the OutputStream buffer- Parameters:
toWrite- a string to writeout- 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.IOExceptionWrites a date to the OutputStream buffer- Parameters:
toWrite- a date to writeout- 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.IOExceptionWrites a long to the OutputStream buffer- Parameters:
length- a long to writein- an input streamout- the OutputStream- Throws:
java.io.IOException- if IO error occurs
-
readInt
public int readInt(java.io.InputStream in) throws java.io.IOExceptionReads 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.IOExceptionReads 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.IOExceptionReads 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.IOExceptionReads 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.IOExceptionReads string with a max length from the InputStream- Parameters:
in- InputStreammaxLength- 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.IOExceptionReads 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.IOExceptionReads stream- Parameters:
in- InputStreamout- 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.IOExceptionFunction called by previous readStream Used to read whole stream- Parameters:
length- length of inputstreamin- input streamout- output stream- Throws:
java.io.IOException- if io error occurs
-
readFully
protected void readFully(byte[] buffer, java.io.InputStream in) throws java.io.IOExceptionFunction 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
-
-