Client and backend. This class is shared: the same code is compiled into your app and into your server, so everything on this page works in both.

public class BufferedReader

  1. Object
  2. Reader
  3. BufferedReader

ImplementsAutoCloseable, Closeable

Reads text from another reader through a buffer, and reads it a line at a time. A line ends at \n, \r or \r\n.

Like most readers, it is for one thread at a time.

Constructors

public BufferedReader(Reader in)Buffers in with an 8192 character buffer.
public BufferedReader(Reader in, int size)Buffers in with a buffer of size characters.

Methods

public int read() throws IOExceptionRead a single character.
public int read(char[] cbuf, int off, int len) throws IOExceptionRead characters into a portion of an array.
public String readLine() throws IOExceptionReads a line of text, without its terminator.
public boolean ready() throws IOExceptionTell whether this stream is ready to be read.
public long skip(long n) throws IOExceptionSkip characters.
public boolean markSupported()Tell whether this stream supports the mark() operation.
public void mark(int readAheadLimit) throws IOExceptionMark the present position in the stream.
public void reset() throws IOExceptionReset the stream.
public void close() throws IOExceptionClose the stream.
public Stream<String> lines()The remaining lines, read as the stream asks for them.

Inherited fields

Inherited methods

Constructor details

BufferedReader

public BufferedReader(Reader in)
Buffers in with an 8192 character buffer.

BufferedReader

public BufferedReader(Reader in, int size)
Buffers in with a buffer of size characters.

Throws

IllegalArgumentException
when size is not positive

Method details

read

public int read() throws IOException
Read a single character. This method will block until a character is available, an I/O error occurs, or the end of the stream is reached. Subclasses that intend to support efficient single-character input should override this method.

read

public int read(char[] cbuf, int off, int len) throws IOException
Read characters into a portion of an array. This method will block until some input is available, an I/O error occurs, or the end of the stream is reached.

readLine

public String readLine() throws IOException
Reads a line of text, without its terminator.

Returns

the line, or null at the end of the text

ready

public boolean ready() throws IOException
Tell whether this stream is ready to be read.

skip

public long skip(long n) throws IOException
Skip characters. This method will block until some characters are available, an I/O error occurs, or the end of the stream is reached.

markSupported

public boolean markSupported()
Tell whether this stream supports the mark() operation. The default implementation always returns false. Subclasses should override this method.

mark

public void mark(int readAheadLimit) throws IOException
Mark the present position in the stream. Subsequent calls to reset() will attempt to reposition the stream to this point. Not all character-input streams support the mark() operation.

reset

public void reset() throws IOException
Reset the stream. If the stream has been marked, then attempt to reposition it at the mark. If the stream has not been marked, then attempt to reset it in some way appropriate to the particular stream, for example by repositioning it to its starting point. Not all character-input streams support the reset() operation, and some support reset() without supporting mark().

close

public void close() throws IOException
Close the stream. Once a stream has been closed, further read(), ready(), mark(), or reset() invocations will throw an IOException. Closing a previously-closed stream, however, has no effect.

lines

public Stream<String> lines()
The remaining lines, read as the stream asks for them. A read that fails surfaces as an UncheckedIOException; closing the stream does not close this reader, as in the JDK.