public final class InputStreams extends Object
InputStream
s.Modifier and Type | Field and Description |
---|---|
static InputStream |
EMPTY
An
InputStream that produces exactly 0 bytes. |
static InputStream |
ZERO
An input stream that reads an endless stream of zeros.
|
Modifier and Type | Method and Description |
---|---|
static InputStream |
byteProducerInputStream(Producer<? extends Byte> delegate) |
static InputStream |
byteProducerInputStream(ProducerWhichThrows<? extends Byte,? extends IOException> delegate) |
static InputStream |
constantInputStream(byte b) |
protected static InputStream |
deleteOnClose(InputStream delegate,
File file) |
static InputStream |
onEndOfInput(InputStream delegate,
Runnable runnable)
Creates and returns an
InputStream that reads from the delegate and invokes the
runnable on the first end-of-input condition. |
static InputStream |
randomInputStream(long seed) |
static byte[] |
readAll(InputStream is)
Equivalent with
readAll(is, false) . |
static byte[] |
readAll(InputStream is,
boolean closeInputStream) |
static String |
readAll(InputStream inputStream,
Charset charset,
boolean closeInputStream) |
static InputStream |
singlingFilterInputStream(InputStream delegate) |
static long |
skip(InputStream inputStream,
long n)
Skips n bytes on the inputStream.
|
static long |
skipAll(InputStream inputStream)
Skips all remaining data on the inputStream.
|
static InputStream |
unclosable(InputStream delegate) |
static InputStream |
wye(InputStream in,
OutputStream out)
Creates and returns a
FilterInputStream that duplicates all bytes read through it and writes them to
an OutputStream . |
public static final InputStream EMPTY
InputStream
that produces exactly 0 bytes.public static final InputStream ZERO
public static InputStream wye(InputStream in, OutputStream out)
FilterInputStream
that duplicates all bytes read through it and writes them to
an OutputStream
.
The OutputStream
is flushed on end-of-input and calls to InputStream.available()
.
public static byte[] readAll(InputStream is) throws IOException
readAll(is, false)
.IOException
public static byte[] readAll(InputStream is, boolean closeInputStream) throws IOException
closeInputStream
- Whether to close the inputStream (also if an IOException
is thrown)InputStream
producesIOException
public static String readAll(InputStream inputStream, Charset charset, boolean closeInputStream) throws IOException
InputStream
produces, decoded into a stringIOException
public static long skip(InputStream inputStream, long n) throws IOException
InputStream.skip(long)
sometimes
skips less than the requested number of bytes for no good reason, e.g. BufferedInputStream.skip(long)
is known for that. This method tries "harder" to skip exactly the requested number of bytes.IOException
InputStream.skip(long)
public static long skipAll(InputStream inputStream) throws IOException
IOException
InputStream.skip(long)
public static InputStream constantInputStream(byte b)
public static InputStream unclosable(InputStream delegate)
InputStream
which ignores all invocations of InputStream.close()
public static InputStream byteProducerInputStream(ProducerWhichThrows<? extends Byte,? extends IOException> delegate)
null
products are returned as 'end-of-input'public static InputStream byteProducerInputStream(Producer<? extends Byte> delegate)
null
products are returned as 'end-of-input'public static InputStream randomInputStream(long seed)
protected static InputStream deleteOnClose(InputStream delegate, File file)
InputStream
which first closes the delegate, and then attempts to delete the
filepublic static InputStream onEndOfInput(InputStream delegate, Runnable runnable)
InputStream
that reads from the delegate and invokes the
runnable on the first end-of-input condition.public static InputStream singlingFilterInputStream(InputStream delegate)
InputStream
for which InputStream.read(byte[], int, int)
returns at most 1Copyright © 2018 Arno Unkrig. All rights reserved.