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

public Class BufferedRandom

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

A buffered reader and writer together for a random access file.
Author
Philip Jenvey

Field Summary

Modifier and TypeField and Description
protected BufferedIOBase
reader

The buffered reader

protected BufferedIOBase
writer

The buffered writer

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

Constructor Summary

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

Construct a BufferedRandom of bufferSize, wrapping the given RawIOBase.

Method Summary

Modifier and TypeMethod and Description
public void
flush()

Overrides org.python.core.io.BufferedIOMixin.flush.

Flushes write buffers, if applicable.

protected void
initChildBuffers()

Initialize the child read/write buffers.

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 ByteBuffer
read(int
the number of bytes to read
size
)

Overrides org.python.core.io.BufferedIOBase.read.

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

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.

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 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:
asInputStreamasOutputStreamcloseclosedfilenoisattyreadabletruncatewritable

Field Detail

readerback to summary
protected BufferedIOBase reader

The buffered reader

writerback to summary
protected BufferedIOBase writer

The buffered writer

Constructor Detail

BufferedRandomback to summary
public BufferedRandom(RawIOBase rawIO, int bufferSize)

Construct a BufferedRandom of bufferSize, wrapping the given RawIOBase.

Method Detail

flushback to summary
public void flush()

Overrides org.python.core.io.BufferedIOMixin.flush.

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

Flushes write buffers, if applicable. This is a no-op for read-only and non-blocking streams.

Annotations
@Override
initChildBuffersback to summary
protected void initChildBuffers()

Initialize the child read/write buffers.

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

readback to summary
public ByteBuffer read(int size)

Overrides org.python.core.io.BufferedIOBase.read.

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

the number of bytes to read

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

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

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