Top Description Fields Constructors Methods
org.python.core.io

public abstract Class BufferedIOBase

extends IOBase
Class Inheritance
Known Direct Subclasses
org.python.core.io.BufferedIOMixin
Imports
java.nio.ByteBuffer

Base class for buffered I/O objects.
Author
Philip Jenvey

Field Summary

Inherited from org.python.core.io.IOBase:
DEFAULT_BUFFER_SIZELF_BYTE

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

boolean whether or not any data is currently buffered
buffered
()

Return true if this objects buffer contains any data.

public void
clear()

Clear the read buffer if one exists.

public ByteBuffer

Returns:

a ByteBuffer containing the bytes read
peek
(int
the minimal number of bytes as an int
size
)

Returns buffered bytes without advancing the position.

public ByteBuffer

Returns:

a ByteBuffer containing the bytes read
read
(int
the number of bytes to read
size
)

Read and return up to size bytes, contained in a ByteBuffer.

public int

Returns:

the amount of data read as an int
read1
(ByteBuffer
a ByteBuffer to read bytes into
bytes
)

Reads up to bytes.remaining() bytes.

public ByteBuffer

Returns:

a ByteBuffer containing the bytes read
readall
()

Read until EOF.

public int

Returns:

the amount of data read as an int
readinto
(ByteBuffer
a ByteBuffer to read bytes into
bytes
)

Read up to bytes.remaining() bytes into the given ByteBuffer.

protected int

Returns:

the amount of data read as an int
readinto
(ByteBuffer
a ByteBuffer to read bytes into
bytes
,
boolean
whether to buffer the remaining bytes of the stream, if we can
buffered
)

Read up to bytes.remaining() bytes into the given ByteBuffer, but control whether to attempt to buffer the rest of the underlying stream.

public int

Returns:

the number of bytes written as an int
write
(ByteBuffer
a ByteBuffer value
bytes
)

Write the given ByteBuffer to the IO stream.

Inherited from org.python.core.io.IOBase:
asInputStreamasOutputStreamcheckClosedcheckReadablecheckWritablecloseclosedfilenoflushisattyreadableseekseektelltruncateunsupportedwritable

Constructor Detail

BufferedIOBaseback to summary
public BufferedIOBase()

Method Detail

bufferedback to summary
public boolean buffered()

Return true if this objects buffer contains any data.

Returns:boolean

boolean whether or not any data is currently buffered

clearback to summary
public void clear()

Clear the read buffer if one exists.

peekback to summary
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:int

the minimal number of bytes as an int

Returns:ByteBuffer

a ByteBuffer containing the bytes read

readback to summary
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:int

the number of bytes to read

Returns:ByteBuffer

a ByteBuffer containing the bytes read

read1back to summary
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:ByteBuffer

a ByteBuffer to read bytes into

Returns:int

the amount of data read as an int

readallback to summary
public ByteBuffer readall()

Read until EOF.

Returns:ByteBuffer

a ByteBuffer containing the bytes read

readintoback to summary
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:ByteBuffer

a ByteBuffer to read bytes into

Returns:int

the amount of data read as an int

readintoback to summary
protected int readinto(ByteBuffer bytes, boolean buffered)

Read up to bytes.remaining() bytes into the given ByteBuffer, but control whether to attempt to buffer the rest of the underlying stream. Returns the number of bytes read (0 for EOF)

Parameters
bytes:ByteBuffer

a ByteBuffer to read bytes into

buffered:boolean

whether to buffer the remaining bytes of the stream, if we can

Returns:int

the amount of data read as an int

writeback to summary
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:ByteBuffer

a ByteBuffer value

Returns:int

the number of bytes written as an int