Package org.python.core.io
Class BufferedIOMixin
- java.lang.Object
-
- org.python.core.io.IOBase
-
- org.python.core.io.BufferedIOBase
-
- org.python.core.io.BufferedIOMixin
-
- Direct Known Subclasses:
BufferedRandom,BufferedReader,BufferedWriter
public abstract class BufferedIOMixin extends BufferedIOBase
A mixin implementation of BufferedIOBase with an underlying raw stream. This passes most requests on to the underlying raw stream. It does *not* provide implementations of read(), readinto() or write().- Author:
- Philip Jenvey
-
-
Field Summary
-
Fields inherited from class org.python.core.io.IOBase
DEFAULT_BUFFER_SIZE
-
-
Constructor Summary
Constructors Constructor Description BufferedIOMixin(RawIOBase rawIO)Initialize this buffer, wrapping the given RawIOBase.BufferedIOMixin(RawIOBase rawIO, int bufferSize)Initialize this buffer, wrapping the given RawIOBase.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.io.InputStreamasInputStream()Coerce this into an InputStream if possible, or return null.java.io.OutputStreamasOutputStream()Coerce this into an OutputStream if possible, or return null.voidclose()Flushes and closes the IO object.booleanclosed()Return whether this file has been closed.RawIOBasefileno()Returns underlying file descriptor if one exists.voidflush()Flushes write buffers, if applicable.booleanisatty()Returns whether this is an 'interactive' stream.booleanreadable()Return whether this file was opened for reading.longseek(long pos, int whence)Seek to byte offsetposrelative to position indicated bywhence.longtell()Return the current stream position.longtruncate(long size)Truncate file to size in bytes.booleanwritable()Return whether this file was opened for writing.-
Methods inherited from class org.python.core.io.BufferedIOBase
buffered, clear, peek, read, read1, readall, readinto, write
-
Methods inherited from class org.python.core.io.IOBase
checkClosed, checkReadable, checkWritable, seek
-
-
-
-
Constructor Detail
-
BufferedIOMixin
public BufferedIOMixin(RawIOBase rawIO)
Initialize this buffer, wrapping the given RawIOBase.- Parameters:
rawIO- a RawIOBase to wrap
-
BufferedIOMixin
public BufferedIOMixin(RawIOBase rawIO, int bufferSize)
Initialize this buffer, wrapping the given RawIOBase.- Parameters:
rawIO- a RawIOBase to wrapbufferSize- the size of the buffer
-
-
Method Detail
-
seek
public long seek(long pos, int whence)Description copied from class:IOBaseSeek to byte offsetposrelative to position indicated bywhence.
Returns the new absolute position.Semantics whenceSeek to pos0 Start of stream (the default). Should be ≥0. 1 Current position + posEither sign. 2 End of stream + posUsually ≤0.
-
tell
public long tell()
Description copied from class:IOBaseReturn the current stream position.
-
truncate
public long truncate(long size)
Description copied from class:IOBaseTruncate file to size in bytes. Returns the new size.
-
flush
public void flush()
Description copied from class:IOBaseFlushes write buffers, if applicable. This is a no-op for read-only and non-blocking streams.
-
close
public void close()
Description copied from class:IOBaseFlushes and closes the IO object. This must be idempotent. It should also set a flag for the 'closed' property (see below) to test.
-
fileno
public RawIOBase fileno()
Description copied from class:IOBaseReturns underlying file descriptor if one exists. Raises IOError if the IO object does not use a file descriptor.
-
isatty
public boolean isatty()
Description copied from class:IOBaseReturns whether this is an 'interactive' stream. Returns False if we don't know.
-
readable
public boolean readable()
Description copied from class:IOBaseReturn whether this file was opened for reading.
-
writable
public boolean writable()
Description copied from class:IOBaseReturn whether this file was opened for writing.
-
closed
public boolean closed()
Description copied from class:IOBaseReturn whether this file has been closed.
-
asInputStream
public java.io.InputStream asInputStream()
Description copied from class:IOBaseCoerce this into an InputStream if possible, or return null.- Overrides:
asInputStreamin classIOBase
-
asOutputStream
public java.io.OutputStream asOutputStream()
Description copied from class:IOBaseCoerce this into an OutputStream if possible, or return null.- Overrides:
asOutputStreamin classIOBase
-
-