public abstract class IOBase
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_BUFFER_SIZE
The default size of generic buffers
|
Constructor and Description |
---|
IOBase() |
Modifier and Type | Method and Description |
---|---|
java.io.InputStream |
asInputStream()
Coerce this into an InputStream if possible, or return null.
|
java.io.OutputStream |
asOutputStream()
Coerce this into an OutputStream if possible, or return null.
|
void |
checkClosed()
Raise a ValueError if the file is closed.
|
void |
checkReadable()
Raise an IOError if the file is not readable.
|
void |
checkWritable()
Raise an IOError if the file is not writable.
|
void |
close()
Flushes and closes the IO object.
|
boolean |
closed()
Return whether this file has been closed.
|
RawIOBase |
fileno()
Returns underlying file descriptor if one exists.
|
void |
flush()
Flushes write buffers, if applicable.
|
boolean |
isatty()
Returns whether this is an 'interactive' stream.
|
boolean |
readable()
Return whether this file was opened for reading.
|
long |
seek(long pos)
Seek to byte offset pos relative to the start of the stream.
|
long |
seek(long pos,
int whence)
Seek to byte offset
pos relative to position indicated by whence . |
long |
tell()
Return the current stream position.
|
long |
truncate(long size)
Truncate file to size in bytes.
|
boolean |
writable()
Return whether this file was opened for writing.
|
public static final int DEFAULT_BUFFER_SIZE
public long seek(long pos)
pos
- a long position valuepublic long seek(long pos, int whence)
pos
relative to position indicated by whence
.
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. |
pos
- a long position valuewhence
- an int whence valuepublic long tell()
public long truncate(long size)
size
- a long size to truncate topublic void flush()
public void close()
public RawIOBase fileno()
public boolean isatty()
public boolean readable()
public void checkReadable()
public boolean writable()
public void checkWritable()
public boolean closed()
public void checkClosed()
public java.io.OutputStream asOutputStream()
public java.io.InputStream asInputStream()