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.Date
readDate(java.io.InputStream in)
Reads date from the InputStreamprotected void
readFully(byte[] buffer, java.io.InputStream in)
Function used by other read funcs Reads from input stream until buffer is fullint
readInt(java.io.InputStream in)
Reads 4 bytes from the InputStreamlong
readLong(java.io.InputStream in)
Reads 8 bytes from the InputStreamvoid
readStream(long length, java.io.InputStream in, java.io.OutputStream out)
Function called by previous readStream Used to read whole streamvoid
readStream(java.io.InputStream in, java.io.OutputStream out)
Reads streamjava.lang.String
readString(java.io.InputStream in)
Reads string from the InputStreamjava.lang.String
readString(java.io.InputStream in, int maxLength)
Reads string with a max length from the InputStreamvoid
writeBytes(byte[] toWrite, java.io.OutputStream out)
Writes an array of bytes to the OutputStream buffervoid
writeDate(java.util.Date toWrite, java.io.OutputStream out)
Writes a date to the OutputStream buffervoid
writeInt(int in, java.io.OutputStream out)
Writes an int to the OutputStream buffervoid
writeLong(long in, java.io.OutputStream out)
Writes an long to the OutputStream buffervoid
writeStream(long length, java.io.InputStream in, java.io.OutputStream out)
Writes a long to the OutputStream buffervoid
writeString(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.IOException
Writes 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.IOException
Writes 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.IOException
Writes 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.IOException
Writes 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.IOException
Writes 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.IOException
Writes 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.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
- 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.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
- 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.IOException
Function 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.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
-
-