Package org.python.core.io
Class BufferedIOBase
java.lang.Object
org.python.core.io.IOBase
org.python.core.io.BufferedIOBase
- Direct Known Subclasses:
BufferedIOMixin
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
-
Method Summary
Modifier and TypeMethodDescriptionboolean
buffered()
Return true if this objects buffer contains any data.void
clear()
Clear the read buffer if one exists.peek
(int size) Returns buffered bytes without advancing the position.read
(int size) Read and return up to size bytes, contained in a ByteBuffer.int
read1
(ByteBuffer bytes) Reads up to bytes.remaining() bytes.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
-
Constructor Details
-
BufferedIOBase
public BufferedIOBase()
-
-
Method Details
-
read
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
Read until EOF.- Returns:
- a ByteBuffer containing the bytes read
-
readinto
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
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
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
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.
-