IOHandler¶
-
public final class
IOHandler
¶ IOHandler provides some convenient methods for handling some basic input and output funtions.
Author: Hugo Y. K. Lam
Methods¶
merge¶
-
public static InputStream
merge
(InputStream ins1, InputStream ins2)¶ Merges the given input streams into one input stream.
Parameters: - ins1 – the first input stream to be merged.
- ins2 – the second input stream to be merged.
Returns: the merged input stream.
pipe¶
-
public static void
pipe
(InputStream ins, OutputStream out)¶ Pipes an input stream to an output stream.
Parameters: - ins – the input stream to be read.
- out – the output stream to be written.
Throws: - IOException – if there is IO error occurred during the operation.
pipe¶
readBytes¶
-
public static byte[]
readBytes
(InputStream ins)¶ Reads an array of bytes from an input stream.
Parameters: - ins – the input stream to be read.
Throws: - IOException – if there is IO error occurred during the operation.
Returns: an array of bytes read from the specified input stream.
readBytes¶
-
public static byte[]
readBytes
(Reader reader, Charset charset)¶ Reads an array of bytes from a reader.
Parameters: - reader – the reader to be read.
- charset – the charset used to convert the characters.
Throws: - IOException – if there is IO error occurred during the operation.
Returns: an array of bytes read from the specified reader.
readString¶
-
public static String
readString
(InputStream ins, Charset charset)¶ Reads a string from an input stream.
Parameters: - ins – the input stream to be read.
- charset – the charset used to convert the bytes.
Throws: - IOException – if there is IO error occurred during the operation.
Returns: a string read from the specified input stream.
readString¶
writeBytes¶
-
public static void
writeBytes
(byte[] bytes, OutputStream out)¶ Writes an array of bytes to an output stream.
Parameters: - bytes – an array of bytes to write.
- out – the output stream to be written.
Throws: - IOException – if there is IO error occurred during the operation.
writeBytes¶
-
public static void
writeBytes
(byte[] bytes, Writer writer, Charset charset)¶ Writes an array of bytes to a writer.
Parameters: - bytes – an array of bytes to write.
- writer – to writer to be written.
- charset – the charset used to convert the bytes.
Throws: - IOException – if there is IO error occurred during the operation.
writeString¶
-
public static void
writeString
(String s, OutputStream out, Charset charset)¶ Writes a string to an output stream.
Parameters: - s – the string to write.
- out – the output stream to be written.
- charset – the charset used to convert the characters.
Throws: - IOException – if there is IO error occurred during the operation.