public class FileIO extends RawIOBase
DEFAULT_BUFFER_SIZE
Constructor and Description |
---|
FileIO(FileChannel fileChannel,
String mode)
Construct a FileIO instance with the given FileChannel.
|
FileIO(PyString name,
String mode)
Construct a FileIO instance for the specified file name, which will be decoded using the
nominal Jython file system encoding if it is a
str/bytes rather than a
unicode . |
FileIO(String name,
String mode) |
Modifier and Type | Method and Description |
---|---|
PyObject |
__add__(PyObject otherObj) |
PyObject |
__int__() |
InputStream |
asInputStream()
Coerce this into an InputStream if possible, or return null.
|
OutputStream |
asOutputStream()
Coerce this into an OutputStream if possible, or return null.
|
void |
close()
Flushes and closes the IO object.
|
FileChannel |
getChannel()
Return the underlying Java nio Channel.
|
FileDescriptor |
getFD() |
boolean |
isatty()
Returns whether this is an 'interactive' stream.
|
boolean |
readable()
Return whether this file was opened for reading.
|
ByteBuffer |
readall()
Read until EOF with one readinto() call.
|
int |
readinto(ByteBuffer buf)
Read up to buf.remaining() bytes into buf.
|
long |
readinto(ByteBuffer[] bufs)
Read bytes into each of the specified ByteBuffers via scatter i/o.
|
long |
seek(long pos,
int whence)
Seek to byte offset pos relative to position indicated by whence: 0 Start of stream (the
default). pos should be >= 0; 1 Current position - whence may be negative; 2 End of stream -
whence usually negative.
|
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.
|
int |
write(ByteBuffer buf)
Write the given ByteBuffer to the IO stream.
|
long |
write(ByteBuffer[] bufs)
Write bytes from each of the specified ByteBuffers via gather
i/o.
|
checkClosed, checkReadable, checkWritable, closed, flush, seek
public FileIO(String name, String mode)
FileIO(PyString name, String mode)
public FileIO(PyString name, String mode)
str/bytes
rather than a
unicode
.
The mode can be 'r', 'w' or 'a' for reading (default), writing or appending. Add a '+' to the
mode to allow simultaneous reading and writing.name
- the name of the filemode
- a raw io file mode Stringpublic FileIO(FileChannel fileChannel, String mode)
fileChannel
- a FileChannel objectmode
- a raw io file mode Stringpublic boolean isatty()
IOBase
public int readinto(ByteBuffer buf)
RawIOBase
public long readinto(ByteBuffer[] bufs)
public ByteBuffer readall()
public int write(ByteBuffer buf)
RawIOBase
public long write(ByteBuffer[] bufs)
public long seek(long pos, int whence)
IOBase
public long tell()
IOBase
public long truncate(long size)
IOBase
public void close()
IOBase
public OutputStream asOutputStream()
IOBase
asOutputStream
in class IOBase
public InputStream asInputStream()
IOBase
asInputStream
in class IOBase
public boolean readable()
IOBase
public boolean writable()
IOBase
public FileChannel getChannel()
RawIOBase
getChannel
in class RawIOBase
public FileDescriptor getFD()
public PyObject __int__()