## org.python.core.io
Class BufferedReader

    java.lang.Object
      org.python.core.io.IOBase
          org.python.core.io.BufferedIOBase
              org.python.core.io.BufferedIOMixin
                  org.python.core.io.BufferedReader

    public class BufferedReader

extends BufferedIOMixin

Buffer for a readable sequential RawIO object.

Author:
  Philip Jenvey

Field Summary

Fields inherited from class org.python.core.io.IOBase
`DEFAULT_BUFFER_SIZE`

Constructor Summary
`BufferedReader(RawIOBase rawIO, int bufferSize)` Construct a BufferedReader of bufferSize, wrapping the given RawIOBase.

Method Summary
`boolean` `buffered()` Return true if this objects buffer contains any data.
`void` `clear()` Clear the read buffer if one exists.
`ByteBuffer` `peek(int size)` Returns buffered bytes without advancing the position.
`int` `read1(ByteBuffer bytes)` Reads up to bytes.remaining() bytes.
`ByteBuffer` `readall()` Read until EOF.
`int` `readinto(ByteBuffer bytes)` Read up to bytes.remaining() bytes into the given ByteBuffer.
`long` `seek(long pos, int whence)` Seek to byte offset pos relative to position indicated by whence: 0 Start of stream (the default). pos should be >= 0; 1 Current position - whence may be negative; 2 End of stream - whence usually negative.
`long` `tell()` Return the current stream position.
`boolean` `writable()` Return whether this file was opened for writing.
`int` `write(ByteBuffer bytes)` Write the given ByteBuffer to the IO stream.

Methods inherited from class org.python.core.io.BufferedIOMixin
`asInputStream, asOutputStream, close, closed, fileno, flush, isatty, readable, truncate`

Methods inherited from class org.python.core.io.BufferedIOBase
`read`

Methods inherited from class org.python.core.io.IOBase
`checkClosed, checkReadable, checkWritable, seek`

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### BufferedReader

    public BufferedReader(RawIOBase rawIO,
                          int bufferSize)

  Construct a BufferedReader of bufferSize, wrapping the given RawIOBase.

  Parameters:
    `rawIO` -
    `bufferSize` -

Method Detail

### readinto

    public int readinto(ByteBuffer bytes)

  Description copied from class: `BufferedIOBase`
  Read up to bytes.remaining() bytes into the given ByteBuffer. Returns number of bytes read (0 for EOF).

  Overrides:
    `readinto` in class `BufferedIOBase`
  Parameters:
    `bytes` - a ByteBuffer to read bytes into
  Returns:
    the amount of data read as an int

### readall

    public ByteBuffer readall()

  Description copied from class: `BufferedIOBase`
  Read until EOF.

  Overrides:
    `readall` in class `BufferedIOBase`
  Returns:
    a ByteBuffer containing the bytes read

### peek

    public ByteBuffer peek(int size)

  Description copied from class: `BufferedIOBase`
  Returns buffered bytes without advancing the position. The argument indicates a desired minimal number of bytes; we do at most one raw read to satisfy it. We never return more than the size of the underlying buffer;

  Overrides:
    `peek` in class `BufferedIOBase`
  Parameters:
    `size` - the minimal number of bytes as an int
  Returns:
    a ByteBuffer containing the bytes read

### read1

    public int read1(ByteBuffer bytes)

  Description copied from class: `BufferedIOBase`
  Reads up to bytes.remaining() bytes. Returns up to bytes.remaining() bytes. If at least one byte is buffered, we only return buffered bytes. Otherwise, we do one raw read.

  Overrides:
    `read1` in class `BufferedIOBase`
  Parameters:
    `bytes` - a ByteBuffer to read bytes into
  Returns:
    the amount of data read as an int

### tell

    public long tell()

  Description copied from class: `IOBase`
  Return the current stream position.

  Overrides:
    `tell` in class `BufferedIOMixin`
  Returns:
    a long position value

### seek

    public long seek(long pos,
                     int whence)

  Description copied from class: `IOBase`
  Seek to byte offset pos relative to position indicated by whence: 0 Start of stream (the default). pos should be >= 0; 1 Current position - whence may be negative; 2 End of stream - whence usually negative. Returns the new absolute position.

  Overrides:
    `seek` in class `BufferedIOMixin`
  Parameters:
    `pos` - a long position value
    `whence` - an int whence value
  Returns:
    a long position value seeked to

### buffered

    public boolean buffered()

  Description copied from class: `BufferedIOBase`
  Return true if this objects buffer contains any data.

  Overrides:
    `buffered` in class `BufferedIOBase`
  Returns:
    boolean whether or not any data is currently buffered

### clear

    public void clear()

  Description copied from class: `BufferedIOBase`
  Clear the read buffer if one exists.

  Overrides:
    `clear` in class `BufferedIOBase`

### write

    public int write(ByteBuffer bytes)

  Description copied from class: `BufferedIOBase`
  Write the given ByteBuffer to the IO stream. Returns the number of bytes written, which may be less than bytes.remaining().

  Overrides:
    `write` in class `BufferedIOBase`
  Parameters:
    `bytes` - a ByteBuffer value
  Returns:
    the number of bytes written as an int

### writable

    public boolean writable()

  Description copied from class: `IOBase`
  Return whether this file was opened for writing.

  Overrides:
    `writable` in class `BufferedIOMixin`
  Returns:
    true if the file was opened for writing

Jython homepage