Package gov.usgs.earthquake.product.io
Class BinaryIO
java.lang.Object
gov.usgs.earthquake.product.io.BinaryIO
Class to read and write Binary streams
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbyte[]
readBytes
(InputStream in) Reads a byte array from the InputStreamreadDate
(InputStream in) Reads date from the InputStreamprotected void
readFully
(byte[] buffer, InputStream in) Function used by other read funcs Reads from input stream until buffer is fullint
readInt
(InputStream in) Reads 4 bytes from the InputStreamlong
readLong
(InputStream in) Reads 8 bytes from the InputStreamvoid
readStream
(long length, InputStream in, OutputStream out) Function called by previous readStream Used to read whole streamvoid
readStream
(InputStream in, OutputStream out) Reads streamReads string from the InputStreamreadString
(InputStream in, int maxLength) Reads string with a max length from the InputStreamvoid
writeBytes
(byte[] toWrite, OutputStream out) Writes an array of bytes to the OutputStream buffervoid
writeDate
(Date toWrite, OutputStream out) Writes a date to the OutputStream buffervoid
writeInt
(int in, OutputStream out) Writes an int to the OutputStream buffervoid
writeLong
(long in, OutputStream out) Writes an long to the OutputStream buffervoid
writeStream
(long length, InputStream in, OutputStream out) Writes a long to the OutputStream buffervoid
writeString
(String toWrite, OutputStream out) Writes a string to the OutputStream buffer
-
Constructor Details
-
BinaryIO
public BinaryIO()
-
-
Method Details
-
writeInt
Writes an int to the OutputStream buffer- Parameters:
in
- an int to writeout
- the OutputStream- Throws:
IOException
- if IO error occurs
-
writeLong
Writes an long to the OutputStream buffer- Parameters:
in
- an long to writeout
- the OutputStream- Throws:
IOException
- if IO error occurs
-
writeBytes
Writes an array of bytes to the OutputStream buffer- Parameters:
toWrite
- an array of bytes to writeout
- the OutputStream- Throws:
IOException
- if IO error occurs
-
writeString
Writes a string to the OutputStream buffer- Parameters:
toWrite
- a string to writeout
- the OutputStream- Throws:
IOException
- if IO error occurs
-
writeDate
Writes a date to the OutputStream buffer- Parameters:
toWrite
- a date to writeout
- the OutputStream- Throws:
IOException
- if IO error occurs
-
writeStream
Writes a long to the OutputStream buffer- Parameters:
length
- a long to writein
- an input streamout
- the OutputStream- Throws:
IOException
- if IO error occurs
-
readInt
Reads 4 bytes from the InputStream- Parameters:
in
- InputStream- Returns:
- an int
- Throws:
IOException
- if IO Error occurs
-
readLong
Reads 8 bytes from the InputStream- Parameters:
in
- InputStream- Returns:
- a long
- Throws:
IOException
- if IO Error occurs
-
readBytes
Reads a byte array from the InputStream- Parameters:
in
- InputStream- Returns:
- Byte[]
- Throws:
IOException
- if IO Error occurs
-
readString
Reads string from the InputStream- Parameters:
in
- InputStream- Returns:
- a string
- Throws:
IOException
- if IO Error occurs
-
readString
Reads string with a max length from the InputStream- Parameters:
in
- InputStreammaxLength
- of string- Returns:
- an string
- Throws:
IOException
- if IO Error occurs
-
readDate
Reads date from the InputStream- Parameters:
in
- InputStream- Returns:
- a date
- Throws:
IOException
- if IO Error occurs
-
readStream
Reads stream- Parameters:
in
- InputStreamout
- OutputStream- Throws:
IOException
- if IO Error occurs
-
readStream
Function called by previous readStream Used to read whole stream- Parameters:
length
- length of inputstreamin
- input streamout
- output stream- Throws:
IOException
- if io error occurs
-
readFully
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
-