public abstract class StreamUtils extends Object
Constructor and Description |
---|
StreamUtils() |
Modifier and Type | Method and Description |
---|---|
static boolean |
compareCharStreams(InputStream s1,
InputStream s2)
Compares the 2 streams.
|
static boolean |
compareCharStreams(Reader s1,
Reader s2)
Compares the 2 streams.
|
static boolean |
compareCharStreams(String s1,
String s2)
Compares the 2 streams.
|
static String |
normalizeLines(Reader charStream,
boolean trim)
Read the lines lines of characters from the stream, trim each line (optional)
and add a single newline character.
|
static String |
normalizeLines(String string,
boolean trim)
Read the lines lines of characters from the supplied string, trim each line (optional)
and add a single newline character.
|
static byte[] |
readFile(File file)
Deprecated.
|
static byte[] |
readStream(InputStream stream)
Read the supplied InputStream and return as a byte array.
|
static String |
readStream(Reader stream) |
static String |
readStreamAsString(InputStream stream)
Read the supplied InputStream and return as a byte array.
|
static StringBuffer |
trimLines(InputStream charStream)
Read the lines lines of characters from the stream and trim each line
i.e.
|
static StringBuffer |
trimLines(Reader charStream)
Read the lines lines of characters from the stream and trim each line
i.e.
|
static String |
trimLines(String charStream)
Read the lines lines of characters from the stream and trim each line
i.e.
|
static void |
writeFile(File file,
byte[] data) |
public static byte[] readStream(InputStream stream) throws IOException
stream
- The stream to read.IOException
- Exception reading from the stream.public static String readStreamAsString(InputStream stream) throws IOException
stream
- The stream to read.IOException
- Exception reading from the stream.public static byte[] readFile(File file) throws IOException
FileUtils.readFile(java.io.File)
.file
- The file to read.IOException
- Error readiong file.public static void writeFile(File file, byte[] data) throws IOException
IOException
public static String readStream(Reader stream) throws IOException
IOException
public static boolean compareCharStreams(InputStream s1, InputStream s2)
trimLines(InputStream)
on each stream before comparing.s1
- Stream 1.s2
- Stream 2.public static boolean compareCharStreams(Reader s1, Reader s2)
trimLines(java.io.Reader)
on each stream before comparing.s1
- Stream 1.s2
- Stream 2.public static boolean compareCharStreams(String s1, String s2)
trimLines(java.io.Reader)
on each stream before comparing.s1
- Stream 1.s2
- Stream 2.public static StringBuffer trimLines(Reader charStream) throws IOException
charStream
- Character stream.IOException
public static String normalizeLines(String string, boolean trim) throws IOException
string
- The String.trim
- Trim each line i.e. to ignore leading and trailing whitespace.IOException
public static String normalizeLines(Reader charStream, boolean trim) throws IOException
charStream
- Character stream.trim
- Trim each line i.e. to ignore leading and trailing whitespace.IOException
public static StringBuffer trimLines(InputStream charStream) throws IOException
charStream
- Character stream.IOException
public static String trimLines(String charStream) throws IOException
charStream
- Character stream.IOException
Copyright © 2020. All rights reserved.