public class StreamUtil extends Object
Constructor and Description |
---|
StreamUtil() |
Modifier and Type | Method and Description |
---|---|
static void |
close(InputStream inStream)
Convenience method that does a null check before closing the stream.
|
static void |
close(OutputStream inStream)
Convenience method that does a null check before closing the stream.
|
static void |
close(Reader inReader)
Convenience function that does a null check before closing the Reader and
wrapps IOExceptions in RuntimeIOExceptions so they don't have to be caught.
|
static void |
close(Writer inWriter)
Convenience function that does a null check before closing the Writer and
wrapps IOExceptions in RuntimeIOExceptions so they don't have to be caught.
|
static int |
fillByteArray(InputStream inStream,
byte[] inByteArray)
Reads bytes from the specified InputStream into the specified byte[].
|
static String |
inputStreamToString(InputStream inStream)
Reads the contents of the specified InputStream into a String.
|
static String |
readerToString(Reader inReader)
Reads the contents of the specified Reader into a String.
|
static void |
writeToFile(InputStream inStream,
File inFile)
Writes the contents of the specified InputStream into the specified File.
|
static void |
writeToStream(InputStream inStream,
OutputStream inOutStream)
Writes the contents of the specified InputStream into the specified OutputStream.
|
public StreamUtil()
public static String inputStreamToString(InputStream inStream) throws IOException
inStream
- the source InputStreamIOException
public static String readerToString(Reader inReader) throws IOException
inReader
- the source ReaderIOException
public static void close(InputStream inStream) throws RuntimeIOException
inStream
- the InputStream to be closedRuntimeIOException
public static void close(OutputStream inStream) throws RuntimeIOException
inStream
- the OutputStream to be closedRuntimeIOException
public static void close(Reader inReader) throws RuntimeIOException
inReader
- the Reader to be closedRuntimeIOException
public static void close(Writer inWriter) throws RuntimeIOException
inWriter
- the Writer to be closedRuntimeIOException
public static void writeToFile(InputStream inStream, File inFile) throws IOException
inStream
- the source InputStreaminFile
- the destination File for the stream contentIOException
public static void writeToStream(InputStream inStream, OutputStream inOutStream) throws IOException
inStream
- the source InputStreaminOutStream
- the destination OutputStreamIOException
public static int fillByteArray(InputStream inStream, byte[] inByteArray) throws IOException
inStream
- the source InputStream for the bytesinByteArray
- the byte[] to be filledIOException