| Modifier and Type | Method and Description |
|---|---|
static byte[] |
asByteArray(InputStream in)
Obtains the contents of the specified stream as a byte array
|
static String |
asUTF8String(InputStream in)
Obtains the contents of the specified stream as a String in UTF-8 charset.
|
static void |
bufferedWriteWithFlush(OutputStream output,
byte[] content)
Writing the specified contents to the specified OutputStream using an internal buffer.
|
static <S extends Closeable> |
closeOnComplete(S stream,
StreamTask<S> task)
Helper method to run a specified task and automatically handle the closing of the stream.
|
static <S extends Closeable> |
closeOnComplete(S stream,
StreamTask<S> task,
StreamErrorHandler errorHandler)
Helper method to run a specified task and automatically handle the closing of the stream.
|
static void |
copy(InputStream input,
OutputStream output)
Copies the contents from an InputStream to an OutputStream.
|
static int |
copy(InputStream input,
OutputStream output,
int len)
Copies the specified number of bytes from an InputStream to an OutputStream.
|
static void |
copyWithClose(InputStream input,
OutputStream output)
Copies the contents from an InputStream to an OutputStream and closes both streams.
|
public static byte[] asByteArray(InputStream in) throws IllegalArgumentException
in - The input stream to be readIllegalArgumentException - If the stream was not specifiedpublic static String asUTF8String(InputStream in)
in - The input stream to be readIllegalArgumentException - If the stream was not specifiedpublic static void copy(InputStream input, OutputStream output) throws IOException
OutputStream will be fully flushed.input - The input stream from which to read the dataoutput - The output stream to which the data will be writtenIOException - If a problem occurred during any I/O operationspublic static int copy(InputStream input, OutputStream output, int len) throws IOException
OutputStream will be fully flushed.input - The input stream from which to read the dataoutput - The output stream to which the data will be writtenlen - the number of bytes to copyIOException - If a problem occurred during any I/O operationspublic static void bufferedWriteWithFlush(OutputStream output, byte[] content) throws IOException
output - The OutputStreamcontent - The content to write to the specified streamIOException - If a problem occurred during any I/O operationspublic static void copyWithClose(InputStream input, OutputStream output) throws IOException
input - The input stream from which to read the dataoutput - The output stream to which the data will be writtenIOException - If a problem occurred during any I/O operations during the copy, but on closing the streams these
will be ignored and logged at Level.FINERpublic static <S extends Closeable> void closeOnComplete(S stream, StreamTask<S> task)
stream - The stream to be closed after the task is executedtask - The task to be executedpublic static <S extends Closeable> void closeOnComplete(S stream, StreamTask<S> task, StreamErrorHandler errorHandler)
S - The type of the streamstream - The stream to be closed after the task is executedtask - The task to be executederrorHandler - The error handler to handle any errors that occur during the execution of the taskCopyright © 2024 JBoss by Red Hat. All rights reserved.