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

public Class BufferedReader

extends BufferedIOMixin
Class Inheritance
Imports
java.nio.ByteBuffer

Buffer for a readable sequential RawIO object.
Author
Philip Jenvey

Field Summary

Modifier and TypeField and Description
protected ByteBuffer
buffer

The underlying buffer

Inherited from org.python.core.io.BufferedIOMixin:
bufferSizerawIO

Constructor Summary

AccessConstructor and Description
public
BufferedReader(RawIOBase rawIO, int bufferSize)

Construct a BufferedReader of bufferSize, wrapping the given RawIOBase.

Method Summary

Modifier and TypeMethod and Description
public boolean
buffered()

Overrides org.python.core.io.BufferedIOBase.buffered.

Return true if this objects buffer contains any data.

public void
clear()

Overrides org.python.core.io.BufferedIOBase.clear.

Clear the read buffer if one exists.

public ByteBuffer
peek(int
the minimal number of bytes as an int
size
)

Overrides org.python.core.io.BufferedIOBase.peek.

Returns buffered bytes without advancing the position.

public int
read1(ByteBuffer
a ByteBuffer to read bytes into
bytes
)

Overrides org.python.core.io.BufferedIOBase.read1.

Reads up to bytes.remaining() bytes.

public ByteBuffer
public int
readinto(ByteBuffer
a ByteBuffer to read bytes into
bytes
)

Overrides org.python.core.io.BufferedIOBase.readinto.

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

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

Overrides org.python.core.io.BufferedIOBase.readinto.

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

public long
seek(long
a long position value
pos
,
int
an int whence value
whence
)

Overrides org.python.core.io.BufferedIOMixin.seek.

Seek to byte offset pos relative to position indicated by whence.

public long
tell()

Overrides org.python.core.io.BufferedIOMixin.tell.

Return the current stream position.

public boolean
writable()

Overrides org.python.core.io.BufferedIOMixin.writable.

Return whether this file was opened for writing.

public int
write(ByteBuffer
a ByteBuffer value
bytes
)

Overrides org.python.core.io.BufferedIOBase.write.

Write the given ByteBuffer to the IO stream.

Inherited from org.python.core.io.BufferedIOMixin:
asInputStreamasOutputStreamcloseclosedfilenoflushisattyreadabletruncate

Field Detail

bufferback to summary
protected ByteBuffer buffer

The underlying buffer

Constructor Detail

BufferedReaderback to summary
public BufferedReader(RawIOBase rawIO, int bufferSize)

Construct a BufferedReader of bufferSize, wrapping the given RawIOBase.

Method Detail

bufferedback to summary
public boolean buffered()

Overrides org.python.core.io.BufferedIOBase.buffered.

Doc from org.python.core.io.BufferedIOBase.buffered.

Return true if this objects buffer contains any data.

Returns:boolean

boolean whether or not any data is currently buffered

Annotations
@Override

clearback to summary
public void clear()

Overrides org.python.core.io.BufferedIOBase.clear.

Doc from org.python.core.io.BufferedIOBase.clear.

Clear the read buffer if one exists.

Annotations
@Override
peekback to summary
public ByteBuffer peek(int size)

Overrides org.python.core.io.BufferedIOBase.peek.

Doc from org.python.core.io.BufferedIOBase.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:int

the minimal number of bytes as an int

Returns:ByteBuffer

a ByteBuffer containing the bytes read

Annotations
@Override

read1back to summary
public int read1(ByteBuffer bytes)

Overrides org.python.core.io.BufferedIOBase.read1.

Doc from org.python.core.io.BufferedIOBase.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:ByteBuffer

a ByteBuffer to read bytes into

Returns:int

the amount of data read as an int

Annotations
@Override

readallback to summary
public ByteBuffer readall()

Overrides org.python.core.io.BufferedIOBase.readall.

Doc from org.python.core.io.BufferedIOBase.readall.

Read until EOF.

Returns:ByteBuffer

a ByteBuffer containing the bytes read

Annotations
@Override

readintoback to summary
public int readinto(ByteBuffer bytes)

Overrides org.python.core.io.BufferedIOBase.readinto.

Doc from org.python.core.io.BufferedIOBase.readinto.

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

Annotations
@Override

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

Overrides org.python.core.io.BufferedIOBase.readinto.

Doc from org.python.core.io.BufferedIOBase.readinto.

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

Annotations
@Override

seekback to summary
public long seek(long pos, int whence)

Overrides org.python.core.io.BufferedIOMixin.seek.

Doc from org.python.core.io.IOBase.seek.

Seek to byte offset pos relative to position indicated by whence.

Semantics
whence Seek to pos
0 Start of stream (the default).Should be ≥0.
1 Current position + pos Either sign.
2 End of stream + pos Usually ≤0.
Returns the new absolute position.
Parameters
pos:long

a long position value

whence:int

an int whence value

Returns:long

a long position value seeked to

Annotations
@Override

tellback to summary
public long tell()

Overrides org.python.core.io.BufferedIOMixin.tell.

Doc from org.python.core.io.IOBase.tell.

Return the current stream position.

Returns:long

a long position value

Annotations
@Override

writableback to summary
public boolean writable()

Overrides org.python.core.io.BufferedIOMixin.writable.

Doc from org.python.core.io.IOBase.writable.

Return whether this file was opened for writing.

Returns:boolean

true if the file was opened for writing

Annotations
@Override

writeback to summary
public int write(ByteBuffer bytes)

Overrides org.python.core.io.BufferedIOBase.write.

Doc from org.python.core.io.BufferedIOBase.write.

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

Annotations
@Override