|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.mockrunner.util.common.StreamUtil
public class StreamUtil
Simple util class for manipulating streams
Constructor Summary | |
---|---|
StreamUtil()
|
Method Summary | |
---|---|
static boolean |
compareReaders(java.io.Reader sourceReader,
java.io.Reader targetReader)
Compares the content of the readers. |
static boolean |
compareStreams(java.io.InputStream sourceStream,
java.io.InputStream targetStream)
Compares the content of the streams. |
static java.io.Reader |
copyReader(java.io.Reader sourceReader)
Returns a copy of the specified reader. |
static java.io.InputStream |
copyStream(java.io.InputStream sourceStream)
Returns a copy of the specified stream. |
static java.util.List |
getLinesFromReader(java.io.Reader reader)
Reads the lines from the specified reader and adds them to a List . |
static java.lang.String |
getReaderAsString(java.io.Reader reader)
Returns the contents of the reader as a string. |
static java.lang.String |
getReaderAsString(java.io.Reader reader,
int length)
Returns the contents of the reader as a string. |
static byte[] |
getStreamAsByteArray(java.io.InputStream stream)
Returns the contents of the input stream as byte array. |
static byte[] |
getStreamAsByteArray(java.io.InputStream stream,
int length)
Returns the contents of the input stream as byte array. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public StreamUtil()
Method Detail |
---|
public static byte[] getStreamAsByteArray(java.io.InputStream stream)
stream
- the InputStream
public static byte[] getStreamAsByteArray(java.io.InputStream stream, int length)
stream
- the InputStream
length
- the number of bytes to copy, if length < 0,
the number is unlimited
public static java.lang.String getReaderAsString(java.io.Reader reader)
reader
- the Reader
String
public static java.lang.String getReaderAsString(java.io.Reader reader, int length)
reader
- the Reader
length
- the number of chars to copy, if length < 0,
the number is unlimited
String
public static java.io.InputStream copyStream(java.io.InputStream sourceStream)
sourceStream
- the stream to copy
public static java.io.Reader copyReader(java.io.Reader sourceReader)
sourceReader
- the stream to reader
public static boolean compareStreams(java.io.InputStream sourceStream, java.io.InputStream targetStream)
sourceStream
- the source streamtargetStream
- the target stream
true
, if the streams are identical, false
otherwisepublic static boolean compareReaders(java.io.Reader sourceReader, java.io.Reader targetReader)
sourceReader
- the source streamtargetReader
- the target stream
true
, if the streams are identical, false
otherwisepublic static java.util.List getLinesFromReader(java.io.Reader reader)
List
.
reader
- the reader
List
with the lines
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |