public final class RandomReader extends Reader
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 |
RandomReader.Builder
A builder for
random readers . |
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes this reader.
|
void |
mark(int readAheadLimit) |
boolean |
markSupported() |
int |
read() |
int |
read(char[] cbuf) |
int |
read(char[] cbuf,
int off,
int len) |
int |
read(CharBuffer target) |
boolean |
ready() |
void |
reset() |
long |
skip(long n) |
static RandomReader.Builder |
usingAllCharacters()
Returns a builder for random readers that can return all possible characters.
|
static RandomReader.Builder |
usingAlphabet(String alphabet)
Returns a builder for random readers that can return characters from a specific alphabet.
|
static RandomReader.Builder |
usingDigits()
Returns a builder for random readers that can return digits.
|
static RandomReader.Builder |
usingGenerator(ToIntFunction<Random> generator)
Returns a builder for random readers that uses a custom generator for characters.
|
static RandomReader.Builder |
usingHex()
Returns a builder for random readers that can return characters from 0-9 and a-z.
|
static RandomReader.Builder |
usingHex(boolean upperCase)
Returns a builder for random readers that can return characters from 0-9 and a-z or A-Z.
|
static RandomReader.Builder |
usingRange(char start,
char end)
Returns a builder for random readers that can return characters from a specific range.
|
public int read(CharBuffer target)
public boolean markSupported()
markSupported
in class Reader
public void close()
public static RandomReader.Builder usingAllCharacters()
public static RandomReader.Builder usingRange(char start, char end)
start
- The start of the range, inclusive.end
- The end of the range, inclusive.IllegalArgumentException
- If start
is larger than end
.public static RandomReader.Builder usingAlphabet(String alphabet)
alphabet
- A string representing the alphabet to use.NullPointerException
- If the given alphabet is null
.IllegalArgumentException
- If the given alphabet is empty.public static RandomReader.Builder usingHex()
public static RandomReader.Builder usingHex(boolean upperCase)
upperCase
- true
to use A-Z, or false
to use a-z.public static RandomReader.Builder usingDigits()
public static RandomReader.Builder usingGenerator(ToIntFunction<Random> generator)
generator
- The generator to use.NullPointerException
- If the given custom generator is null
.Copyright © 2020–2024. All rights reserved.