Package at.gv.egovernment.moaspss.util
Class StreamUtils
java.lang.Object
at.gv.egovernment.moaspss.util.StreamUtils
Utility methods for streams.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleancompareStreams(InputStream is1, InputStream is2) Compare the contents of twoInputStreams.static StringGets the stack trace of theThrowablepassed in as a string.static byte[]Reads a byte array from a stream.static StringreadStream(InputStream in, String encoding) Reads aStringfrom a stream, using given encoding.
-
Constructor Details
-
StreamUtils
public StreamUtils()
-
-
Method Details
-
compareStreams
Compare the contents of twoInputStreams.- Parameters:
is1- The 1stInputStreamto compare.is2- The 2ndInputStreamto compare.- Returns:
- boolean
true, if both streams contain the exactly the same content,falseotherwise. - Throws:
IOException- An error occurred reading one of the streams.
-
readStream
Reads a byte array from a stream.- Parameters:
in- TheInputStreamto read.- Returns:
- The bytes contained in the given
InputStream. - Throws:
IOException- on any exception thrown
-
readStream
Reads aStringfrom a stream, using given encoding.- Parameters:
in- TheInputStreamto read.encoding- The character encoding to use for converting the bytes of theInputStreaminto aString.- Returns:
- The content of the given
InputStreamconverted into aString. - Throws:
IOException- on any exception thrown
-
getStackTraceAsString
Gets the stack trace of theThrowablepassed in as a string.- Parameters:
t- TheThrowable.- Returns:
- a String representing the stack trace of the
Throwable.
-