public final class RandomInputStream extends InputStream
mark(int)
and reset()
. It comes with a default mark at the start of the stream, which means that
reset()
can be called at any time.Modifier and Type | Class and Description |
---|---|
static class |
RandomInputStream.Builder
A builder for
random input streams . |
Modifier and Type | Method and Description |
---|---|
int |
available() |
void |
close()
Closes this input stream.
|
void |
mark(int readAheadLimit) |
boolean |
markSupported() |
int |
read() |
int |
read(byte[] cbuf) |
int |
read(byte[] b,
int off,
int len) |
void |
reset() |
long |
skip(long n) |
static RandomInputStream.Builder |
usingAllBytes()
Returns a builder for random input streams that can return all possible bytes.
|
static RandomInputStream.Builder |
usingGenerator(ToIntFunction<Random> generator)
Returns a builder for random input streams that uses a custom generator for bytes.
|
static RandomInputStream.Builder |
usingRange(int start,
int end)
Returns a builder for random input streams that can return bytes from a specific range.
|
static RandomInputStream.Builder |
usingRangeFrom(int start)
Returns a builder for random input streams that can return bytes from a specific range.
|
static RandomInputStream.Builder |
usingRangeUntil(int end)
Returns a builder for random input streams that can return bytes from a specific range.
|
public int read()
read
in class InputStream
public int read(byte[] cbuf)
read
in class InputStream
public int read(byte[] b, int off, int len)
read
in class InputStream
public long skip(long n)
skip
in class InputStream
public int available()
available
in class InputStream
public boolean markSupported()
markSupported
in class InputStream
public void mark(int readAheadLimit)
mark
in class InputStream
public void reset()
reset
in class InputStream
public void close()
close
in interface Closeable
close
in interface AutoCloseable
close
in class InputStream
public static RandomInputStream.Builder usingAllBytes()
public static RandomInputStream.Builder usingRange(int start, int end)
0
and 255
or 0xFF
.start
- The start of the range, inclusive.end
- The end of the range, inclusive.IllegalArgumentException
- If start
is larger than end
.public static RandomInputStream.Builder usingRangeFrom(int start)
usingRange(start, 0xFF)
.start
- The start of the range, inclusive.public static RandomInputStream.Builder usingRangeUntil(int end)
usingRange(0, end)
.end
- The end of the range, inclusive.public static RandomInputStream.Builder usingGenerator(ToIntFunction<Random> generator)
generator
- The generator to use.NullPointerException
- If the given custom generator is null
.Copyright © 2020–2024. All rights reserved.