public class PeekableReader extends Reader
Constructor and Description |
---|
PeekableReader(Reader reader)
Creates a new
PeekableReader instance. |
Modifier and Type | Method and Description |
---|---|
void |
close() |
boolean |
hasNext()
Returns
true if the reader has more characters. |
void |
mark(int readAheadLimit) |
boolean |
markSupported() |
char |
next()
Returns the next character of the reader.
|
char |
peek()
Returns the next character in the reader, returned by
read() ,
without removing it from the I/O stream. |
int |
read() |
int |
read(char[] buffer,
int offset,
int length) |
void |
reset() |
public PeekableReader(Reader reader)
PeekableReader
instance.reader
- The wrapped readerpublic void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class Reader
IOException
public final boolean hasNext() throws IOException
true
if the reader has more characters. (In other words,
returns true
if next()
would return a character rather than
throwing an exception.)true
if the reader has more characters, else false
IOException
- if an I/O error occurspublic void mark(int readAheadLimit) throws IOException
mark
in class Reader
IOException
public boolean markSupported()
markSupported
in class Reader
public final char next() throws IOException
IOException
- if an I/O error occursNoSuchElementException
- if the reader has no more characterspublic char peek() throws IOException
read()
,
without removing it from the I/O stream.IOException
- if an I/O error occursNoSuchElementException
- if the iteration has no more elementspublic int read() throws IOException
read
in class Reader
IOException
public int read(@Nullable char[] buffer, int offset, int length) throws IOException
read
in class Reader
IOException
public void reset() throws IOException
reset
in class Reader
IOException
Copyright © 2025. All rights reserved.