- java.lang.Object
-
- org.hsqldb.lib.InOutUtil
-
public final class InOutUtil extends java.lang.Object
Input / Output utility- Since:
- 1.7.2
- Author:
- Fred Toussi (fredt@users dot sourceforge.net), Campbell Burnet (campbell-burnet@users dot sourceforge.net)
-
-
Field Summary
Fields Modifier and Type Field Description static long
DEFAULT_COPY_AMOUNT
static int
DEFAULT_COPY_BUFFER_SIZE
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static long
copy(java.io.InputStream inputStream, java.io.OutputStream outputStream)
static long
copy(java.io.InputStream inputStream, java.io.OutputStream outputStream, long amount)
static long
copy(java.io.InputStream inputStream, java.io.OutputStream outputStream, long amount, int bufferSize)
the specifiedamount
from the given input stream to the given output stream, using a buffer of the given size.static long
copy(java.io.Reader reader, java.io.Writer writer)
static long
copy(java.io.Reader reader, java.io.Writer writer, long amount)
static long
copy(java.io.Reader reader, java.io.Writer writer, long amount, int bufferSize)
the specifiedamount
from the given input stream to the given output stream, using a buffer of the given size.static java.io.Serializable
deserialize(byte[] ba)
Deserializes the specified byte array to anObject
instance.static int
readLine(java.io.InputStream in, java.io.OutputStream out)
Implementation only supports unix line-end format and is suitable for processing HTTP and other network protocol communications.static byte[]
serialize(java.io.Serializable s)
Retrieves the serialized form of the specifiedObject
as an array of bytes.
-
-
-
Field Detail
-
DEFAULT_COPY_BUFFER_SIZE
public static final int DEFAULT_COPY_BUFFER_SIZE
- See Also:
- Constant Field Values
-
DEFAULT_COPY_AMOUNT
public static final long DEFAULT_COPY_AMOUNT
- See Also:
- Constant Field Values
-
-
Method Detail
-
readLine
public static int readLine(java.io.InputStream in, java.io.OutputStream out) throws java.io.IOException
Implementation only supports unix line-end format and is suitable for processing HTTP and other network protocol communications. Reads and writes a line of data. Returns the number of bytes read/written.- Parameters:
in
- InputStreamout
- OutputStream- Returns:
- int
- Throws:
java.io.IOException
- on failure
-
serialize
public static byte[] serialize(java.io.Serializable s) throws java.io.IOException
Retrieves the serialized form of the specifiedObject
as an array of bytes.- Parameters:
s
- the Object to serialize- Returns:
- a static byte array representing the passed Object
- Throws:
java.io.IOException
- on failure
-
deserialize
public static java.io.Serializable deserialize(byte[] ba) throws java.io.IOException, java.lang.ClassNotFoundException
Deserializes the specified byte array to anObject
instance.- Parameters:
ba
- the byte array to deserialize to an Object- Returns:
- the Object resulting from deserializing the specified array of bytes
- Throws:
java.io.IOException
- on failurejava.lang.ClassNotFoundException
- if not found
-
copy
public static long copy(java.io.InputStream inputStream, java.io.OutputStream outputStream) throws java.io.IOException
- Parameters:
inputStream
- InputStreamoutputStream
- OutputStream- Returns:
- long
- Throws:
java.io.IOException
- on failure- See Also:
copy(java.io.InputStream, java.io.OutputStream, long, int)
-
copy
public static long copy(java.io.InputStream inputStream, java.io.OutputStream outputStream, long amount) throws java.io.IOException
- Parameters:
inputStream
- InputStreamoutputStream
- OutputStreamamount
- long- Returns:
- long
- Throws:
java.io.IOException
- on failure- See Also:
copy(java.io.InputStream, java.io.OutputStream, long, int)
-
copy
public static long copy(java.io.InputStream inputStream, java.io.OutputStream outputStream, long amount, int bufferSize) throws java.io.IOException
the specifiedamount
from the given input stream to the given output stream, using a buffer of the given size.- Parameters:
inputStream
- from which to source bytesoutputStream
- to which to sink bytesamount
- max # of bytes to transfer.bufferSize
- to use internally- Returns:
- the number of bytes actually transferred.
- Throws:
java.io.IOException
- if any, thrown by either of the given stream objects
-
copy
public static long copy(java.io.Reader reader, java.io.Writer writer) throws java.io.IOException
- Parameters:
reader
- Readerwriter
- Writer- Returns:
- long
- Throws:
java.io.IOException
- on failure- See Also:
copy(java.io.Reader, java.io.Writer, long, int)
-
copy
public static long copy(java.io.Reader reader, java.io.Writer writer, long amount) throws java.io.IOException
- Parameters:
reader
- Readerwriter
- Writeramount
- long- Returns:
- long
- Throws:
java.io.IOException
- on failure- See Also:
copy(java.io.Reader, java.io.Writer, long, int)
-
copy
public static long copy(java.io.Reader reader, java.io.Writer writer, long amount, int bufferSize) throws java.io.IOException
the specifiedamount
from the given input stream to the given output stream, using a buffer of the given size.- Parameters:
reader
- from which to source characterswriter
- to which to sink charactersamount
- max # of characters to transfer.bufferSize
- to use internally- Returns:
- the number of characters actually transferred.
- Throws:
java.io.IOException
- if any, thrown by either of the given stream objects
-
-