public class StreamUtils extends Object
| Constructor and Description |
|---|
StreamUtils() |
| Modifier and Type | Method and Description |
|---|---|
static byte[] |
read(InputStream in)
Reads an input stream and writes it to a byte array
|
static String |
read(InputStream in,
String charset)
Reads an input stream and writes it to a string, using the desired charset
|
static String |
readAsUTF8(InputStream in)
Reads an input stream and writes it to a string, using UTF-8 charset
|
static void |
safeCloseStream(InputStream in)
Close streams without pain
|
static void |
safeCloseStream(OutputStream out)
Close streams without pain
|
static void |
safeCloseStreams(InputStream in,
OutputStream out)
Close streams without pain
|
static void |
write(InputStream in,
OutputStream out,
boolean closeBoth)
Writes the input stream to the output stream.
|
static void |
write(String in,
OutputStream out,
boolean closeBoth)
Writes the input stream to the output stream.
|
public static byte[] read(InputStream in) throws IOException
responseBodyAsStream - IOExceptionpublic static String read(InputStream in, String charset) throws IOException
responseBodyAsStream - IOExceptionpublic static String readAsUTF8(InputStream in) throws IOException
responseBodyAsStream - IOExceptionpublic static void write(InputStream in, OutputStream out, boolean closeBoth) throws IOException
responseBodyAsStream - IOExceptionpublic static void write(String in, OutputStream out, boolean closeBoth) throws IOException
responseBodyAsStream - IOExceptionpublic static void safeCloseStream(InputStream in)
in - public static void safeCloseStream(OutputStream out)
out - public static void safeCloseStreams(InputStream in, OutputStream out)
out - in - Copyright © 2016. All rights reserved.