public final class StreamUtils extends Object
Modifier and Type | Method and Description |
---|---|
static boolean |
compareStreams(InputStream in1,
InputStream in2)
Compares if two streams are identical in their contents.
|
static void |
copyReaderToStream(Reader in,
OutputStream out,
String encoding,
boolean close)
Copies the content of the Reader to the provided OutputStream using the provided encoding.
|
static void |
copyReaderToWriter(Reader input,
Writer output,
boolean close)
Copies the Reader to the Writer.
|
static void |
copyStream(InputStream src,
OutputStream dest,
boolean closeStreams)
Copy a stream.
|
static void |
copyStream(StreamMonitor monitor,
URL sourceURL,
int expected,
InputStream source,
OutputStream destination,
boolean closeStreams)
Copy a stream.
|
static void |
copyStreamToWriter(InputStream in,
Writer out,
String encoding,
boolean close)
Copies an InputStream to a Writer.
|
public static void copyStream(InputStream src, OutputStream dest, boolean closeStreams) throws IOException, NullArgumentException
src
- the source input streamdest
- the destination output streamcloseStreams
- TRUE if the streams should be closed on completionIOException
- if an IO error occursNullArgumentException
- if either the src or dest arguments are null.public static void copyStream(StreamMonitor monitor, URL sourceURL, int expected, InputStream source, OutputStream destination, boolean closeStreams) throws IOException, NullArgumentException
sourceURL
- the source urlexpected
- the expected size in bytessource
- the source input streamdestination
- the destination output streamcloseStreams
- TRUE if the streams should be closed on completionmonitor
- The StreamMonitor to report progress to.IOException
- if an IO error occursNullArgumentException
- if either the src or dest arguments are null.public static boolean compareStreams(InputStream in1, InputStream in2) throws IOException
in1
- The first stream.in2
- The second stream.IOException
- If an underlying I/O problem occured.public static void copyReaderToWriter(Reader input, Writer output, boolean close) throws IOException
input
- The input characters.output
- The destination of the characters.close
- true if the reader and writer should be closed after the operation is completed.IOException
- If an underlying I/O problem occured.public static void copyStreamToWriter(InputStream in, Writer out, String encoding, boolean close) throws IOException
in
- The input byte stream of data.out
- The Writer to receive the streamed data as characters.encoding
- The encoding used in the byte stream.close
- true if the Reader and OutputStream should be closed after the completion.IOException
- If an underlying I/O Exception occurs.public static void copyReaderToStream(Reader in, OutputStream out, String encoding, boolean close) throws IOException
in
- The character data to convert.out
- The OutputStream to send the data to.encoding
- The character encoding that should be used for the byte stream.close
- true if the Reader and OutputStream should be closed after the completion.IOException
- If an underlying I/O Exception occurs.Copyright © 2006–2019 OPS4J - Open Participation Software for Java. All rights reserved.