Package org.python.core.io
Class BufferedWriter
java.lang.Object
org.python.core.io.IOBase
org.python.core.io.BufferedIOBase
org.python.core.io.BufferedIOMixin
org.python.core.io.BufferedWriter
- Direct Known Subclasses:
LineBufferedWriter
Buffer for a writable sequential RawIO object.
- Author:
- Philip Jenvey
-
Field Summary
Fields inherited from class org.python.core.io.IOBase
DEFAULT_BUFFER_SIZE -
Constructor Summary
ConstructorsConstructorDescriptionBufferedWriter(RawIOBase rawIO, int bufferSize) Construct a BufferedWriter of bufferSize, wrapping the given RawIOBase. -
Method Summary
Modifier and TypeMethodDescriptionbooleanbuffered()Return true if this objects buffer contains any data.voidflush()Flushes write buffers, if applicable.intread1(ByteBuffer bytes) Reads up to bytes.remaining() bytes.booleanreadable()Return whether this file was opened for reading.readall()Read until EOF.intreadinto(ByteBuffer bytes) Read up to bytes.remaining() bytes into the given ByteBuffer.longseek(long pos, int whence) Seek to byte offsetposrelative to position indicated bywhence.longtell()Return the current stream position.intwrite(ByteBuffer bytes) Write the given ByteBuffer to the IO stream.Methods inherited from class org.python.core.io.BufferedIOMixin
asInputStream, asOutputStream, close, closed, fileno, isatty, truncate, writableMethods inherited from class org.python.core.io.BufferedIOBase
clear, peek, readMethods inherited from class org.python.core.io.IOBase
checkClosed, checkReadable, checkWritable, seek
-
Constructor Details
-
BufferedWriter
Construct a BufferedWriter of bufferSize, wrapping the given RawIOBase.- Parameters:
rawIO-bufferSize-
-
-
Method Details
-
write
Description copied from class:BufferedIOBaseWrite the given ByteBuffer to the IO stream. Returns the number of bytes written, which may be less than bytes.remaining().- Overrides:
writein classBufferedIOBase- Parameters:
bytes- a ByteBuffer value- Returns:
- the number of bytes written as an int
-
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.- Overrides:
flushin classBufferedIOMixin
-
tell
public long tell()Description copied from class:IOBaseReturn the current stream position.- Overrides:
tellin classBufferedIOMixin- Returns:
- a long position value
-
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. - Overrides:
seekin classBufferedIOMixin- Parameters:
pos- a long position valuewhence- an int whence value- Returns:
- a long position value seeked to
-
buffered
public boolean buffered()Description copied from class:BufferedIOBaseReturn true if this objects buffer contains any data.- Overrides:
bufferedin classBufferedIOBase- Returns:
- boolean whether or not any data is currently buffered
-
readall
Description copied from class:BufferedIOBaseRead until EOF.- Overrides:
readallin classBufferedIOBase- Returns:
- a ByteBuffer containing the bytes read
-
readinto
Description copied from class:BufferedIOBaseRead up to bytes.remaining() bytes into the given ByteBuffer. Returns number of bytes read (0 for EOF).- Overrides:
readintoin classBufferedIOBase- Parameters:
bytes- a ByteBuffer to read bytes into- Returns:
- the amount of data read as an int
-
read1
Description copied from class:BufferedIOBaseReads 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.- Overrides:
read1in classBufferedIOBase- Parameters:
bytes- a ByteBuffer to read bytes into- Returns:
- the amount of data read as an int
-
readable
public boolean readable()Description copied from class:IOBaseReturn whether this file was opened for reading.- Overrides:
readablein classBufferedIOMixin- Returns:
- true if the file was opened for reading
-