public final class Streams extends Object
Constructor and Description |
---|
Streams() |
Modifier and Type | Method and Description |
---|---|
static void |
drain(InputStream inStr)
Read stream till EOF is encountered.
|
static void |
pipeAll(InputStream inStr,
OutputStream outStr)
Write the full contents of inStr to the destination stream outStr.
|
static long |
pipeAllLimited(InputStream inStr,
long limit,
OutputStream outStr)
Write up to limit bytes of data from inStr to the destination stream outStr.
|
static byte[] |
readAll(InputStream inStr)
Read stream fully, returning contents in a byte array.
|
static byte[] |
readAllLimited(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(InputStream inStr,
byte[] buf)
Fully read in buf's length in data, or up to EOF, whichever occurs first,
|
static int |
readFully(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(ByteArrayOutputStream buf,
OutputStream output) |
public static void drain(InputStream inStr) throws IOException
inStr
- stream to be emptied.IOException
- in case of underlying IOException.public static byte[] readAll(InputStream inStr) throws IOException
inStr
- stream to be read.IOException
- in case of underlying IOException.public static byte[] readAllLimited(InputStream inStr, int limit) throws IOException
inStr
- stream to be read.limit
- maximum number of bytes that can be read.IOException
- in case of underlying IOException, or if limit is reached on inStr still has data in it.public static int readFully(InputStream inStr, byte[] buf) throws IOException
inStr
- the stream to be read.buf
- the buffer to be read into.IOException
- in case of underlying IOException.public static int readFully(InputStream inStr, byte[] buf, int off, int len) throws 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.IOException
- in case of underlying IOException.public static void pipeAll(InputStream inStr, OutputStream outStr) throws IOException
inStr
- source input stream.outStr
- destination output stream.IOException
- in case of underlying IOException.public static long pipeAllLimited(InputStream inStr, long limit, OutputStream outStr) throws IOException
inStr
- source input stream.limit
- the maximum number of bytes allowed to be read.outStr
- destination output stream.IOException
- in case of underlying IOException, or if limit is reached on inStr still has data in it.public static void writeBufTo(ByteArrayOutputStream buf, OutputStream output) throws IOException
IOException
Copyright © 2018 BouncyCastle.org. All rights reserved.