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

public abstract Class RawIOBase

extends IOBase
Class Inheritance
Known Direct Subclasses
org.python.core.io.SocketIOBase, org.python.core.io.StreamIO, org.python.core.io.FileIO
Imports
java.nio.ByteBuffer, java.nio.channels.Channel, org.python.core.Py

Base class for raw binary I/O. RawIOBases wrap raw Java I/O objects (typically nio Channels). They provide a convenient means of handling raw Java I/O objects in the context of Python files. RawIOBases maintain state about their underlying I/O objects (such as their mode) and translate Java exceptions into PyExceptions. The read() method is implemented by calling readinto(); derived classes that want to support read() only need to implement readinto() as a primitive operation. In general, readinto() can be more efficient than read().
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 RawIOBase
fileno()

Overrides org.python.core.io.IOBase.fileno.

Returns underlying file descriptor if one exists.

public abstract Channel

Returns:

the underlying Java nio Channel
getChannel
()

Return the underlying Java nio Channel.

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 ByteBuffer

Returns:

a ByteBuffer containing the bytes read
readall
()

Read until EOF, using multiple read() calls.

public int

Returns:

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

Read up to buf.remaining() bytes into buf.

public long

Returns:

the amount of data read as a long
readinto
(ByteBuffer[]
an array of ByteBuffers to read bytes into
bufs
)

Read bytes into each of the specified ByteBuffers.

public int

Returns:

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

Write the given ByteBuffer to the IO stream.

public long

Returns:

the number of bytes written as a long
write
(ByteBuffer[]
an array of ByteBuffers
bufs
)

Write the given ByteBuffers to the IO stream.

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

Constructor Detail

RawIOBaseback to summary
public RawIOBase()

Method Detail

filenoback to summary
public RawIOBase fileno()

Overrides org.python.core.io.IOBase.fileno.

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

Returns underlying file descriptor if one exists. Raises IOError if the IO object does not use a file descriptor.

Returns:RawIOBase

a file descriptor

Annotations
@Override

getChannelback to summary
public abstract Channel getChannel()

Return the underlying Java nio Channel.

Returns:Channel

the underlying Java nio Channel

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

readallback to summary
public ByteBuffer readall()

Read until EOF, using multiple read() calls.

Returns:ByteBuffer

a ByteBuffer containing the bytes read

readintoback to summary
public int readinto(ByteBuffer buf)

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

Parameters
buf:ByteBuffer

a ByteBuffer to read bytes into

Returns:int

the amount of data read as an int

readintoback to summary
public long readinto(ByteBuffer[] bufs)

Read bytes into each of the specified ByteBuffers. Returns number of bytes read (0 for EOF).

Parameters
bufs:ByteBuffer[]

an array of ByteBuffers to read bytes into

Returns:long

the amount of data read as a long

writeback to summary
public int write(ByteBuffer buf)

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

Parameters
buf:ByteBuffer

a ByteBuffer value

Returns:int

the number of bytes written as an int

writeback to summary
public long write(ByteBuffer[] bufs)

Write the given ByteBuffers to the IO stream. Returns the number of bytes written, which may be less than the combined value of all the buf.remaining()'s.

Parameters
bufs:ByteBuffer[]

an array of ByteBuffers

Returns:long

the number of bytes written as a long