public final class Streams
extends java.lang.Object
| Constructor and Description |
|---|
Streams() |
| Modifier and Type | Method and Description |
|---|---|
static void |
drain(java.io.InputStream inStr)
Read stream till EOF is encountered.
|
static void |
pipeAll(java.io.InputStream inStr,
java.io.OutputStream outStr)
Write the full contents of inStr to the destination stream outStr.
|
static long |
pipeAllLimited(java.io.InputStream inStr,
long limit,
java.io.OutputStream outStr)
Write up to limit bytes of data from inStr to the destination stream outStr.
|
static byte[] |
readAll(java.io.InputStream inStr)
Read stream fully, returning contents in a byte array.
|
static byte[] |
readAllLimited(java.io.InputStream inStr,
int limit)
Read from inStr up to a maximum number of bytes, throwing an exception if more the maximum amount
of requested data is available.
|
static int |
readFully(java.io.InputStream inStr,
byte[] buf)
Fully read in buf's length in data, or up to EOF, whichever occurs first,
|
static int |
readFully(java.io.InputStream inStr,
byte[] buf,
int off,
int len)
Fully read in len's bytes of data into buf, or up to EOF, whichever occurs first,
|
static void |
writeBufTo(java.io.ByteArrayOutputStream buf,
java.io.OutputStream output) |
public static void drain(java.io.InputStream inStr)
throws java.io.IOException
inStr - stream to be emptied.java.io.IOException - in case of underlying IOException.public static byte[] readAll(java.io.InputStream inStr)
throws java.io.IOException
inStr - stream to be read.java.io.IOException - in case of underlying IOException.public static byte[] readAllLimited(java.io.InputStream inStr,
int limit)
throws java.io.IOException
inStr - stream to be read.limit - maximum number of bytes that can be read.java.io.IOException - in case of underlying IOException, or if limit is reached on inStr still has data in it.public static int readFully(java.io.InputStream inStr,
byte[] buf)
throws java.io.IOException
inStr - the stream to be read.buf - the buffer to be read into.java.io.IOException - in case of underlying IOException.public static int readFully(java.io.InputStream inStr,
byte[] buf,
int off,
int len)
throws java.io.IOException
inStr - the stream to be read.buf - the buffer to be read into.off - offset into buf to start putting bytes into.len - the number of bytes to be read.java.io.IOException - in case of underlying IOException.public static void pipeAll(java.io.InputStream inStr,
java.io.OutputStream outStr)
throws java.io.IOException
inStr - source input stream.outStr - destination output stream.java.io.IOException - in case of underlying IOException.public static long pipeAllLimited(java.io.InputStream inStr,
long limit,
java.io.OutputStream outStr)
throws java.io.IOException
inStr - source input stream.limit - the maximum number of bytes allowed to be read.outStr - destination output stream.java.io.IOException - in case of underlying IOException, or if limit is reached on inStr still has data in it.public static void writeBufTo(java.io.ByteArrayOutputStream buf,
java.io.OutputStream output)
throws java.io.IOException
java.io.IOException