BufferedIOBase (Jython API documentation)
Date: 2012-08-13

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.python.core.io
Class BufferedIOBase

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

Direct Known Subclasses:
  BufferedIOMixin

    public abstract class BufferedIOBase

extends IOBase

Base class for buffered I/O objects.

Author:
  Philip Jenvey

Field Summary

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

Constructor Summary
`BufferedIOBase()`

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.
`ByteBuffer` | `read(int size)` Read and return up to size bytes, contained in a ByteBuffer.
`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.
`int` | `write(ByteBuffer bytes)` Write the given ByteBuffer to the IO stream.

Methods inherited from class org.python.core.io.IOBase
`asInputStream, asOutputStream, checkClosed, checkReadable, checkWritable, close, closed, fileno, flush, isatty, readable, seek, seek, tell, truncate, writable`

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

Constructor Detail

### BufferedIOBase

    public BufferedIOBase()

Method Detail

### read

    public ByteBuffer read(int size)

  Read and return up to size bytes, contained in a ByteBuffer. ByteBuffers returned from read are already flip()'d. Returns an empty ByteBuffer on EOF

  Parameters:
    `size` - the number of bytes to read
  Returns:
    a ByteBuffer containing the bytes read

### readall

    public ByteBuffer readall()

  Read until EOF.

  Returns:
    a ByteBuffer containing the bytes read

### readinto

    public int readinto(ByteBuffer bytes)

  Read up to bytes.remaining() bytes into the given ByteBuffer. Returns number of bytes read (0 for EOF).

  Parameters:
    `bytes` - a ByteBuffer to read bytes into
  Returns:
    the amount of data read as an int

### write

    public int write(ByteBuffer bytes)

  Write the given ByteBuffer to the IO stream. Returns the number of bytes written, which may be less than bytes.remaining().

  Parameters:
    `bytes` - a ByteBuffer value
  Returns:
    the number of bytes written as an int

### peek

    public ByteBuffer peek(int size)

  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;

  Parameters:
    `size` - the minimal number of bytes as an int
  Returns:
    a ByteBuffer containing the bytes read

### read1

    public int read1(ByteBuffer bytes)

  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.

  Parameters:
    `bytes` - a ByteBuffer to read bytes into
  Returns:
    the amount of data read as an int

### buffered

    public boolean buffered()

  Return true if this objects buffer contains any data.

  Returns:
    boolean whether or not any data is currently buffered

### clear

    public void clear()

  Clear the read buffer if one exists.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Jython homepage