public class FileInputOutput extends AbstractBinaryOutput implements BinaryInput, BinaryOutput, LockableStream, EnvCleanup
SEEK_CUR, SEEK_END, SEEK_SET| Constructor and Description |
|---|
FileInputOutput(Env env,
Path path) |
FileInputOutput(Env env,
Path path,
boolean append,
boolean truncate) |
FileInputOutput(Env env,
Path path,
boolean append,
boolean truncate,
boolean temporary) |
| Modifier and Type | Method and Description |
|---|---|
StringValue |
appendTo(StringValue builder)
Appends to a string builder.
|
void |
cleanup()
Implements the EnvCleanup interface.
|
void |
close()
Closes the file.
|
void |
closeRead()
Closes the file for reading.
|
void |
closeWrite()
Closes the file for writing.
|
void |
flush()
Flushes the output.
|
int |
getAvailable() |
java.io.InputStream |
getInputStream()
Returns the read stream.
|
java.io.OutputStream |
getOutputStream()
Returns the write stream.
|
Path |
getPath()
Returns the path.
|
long |
getPosition()
Returns the current location in the file.
|
boolean |
isEOF()
Returns true on the EOF.
|
boolean |
lock(boolean shared,
boolean block)
Lock the shared advisory lock.
|
BinaryInput |
openCopy()
Opens a copy.
|
void |
print(char v)
Prints a string to a file.
|
void |
print(java.lang.String v)
Prints a string to a file.
|
int |
read()
Reads a character from a file, returning -1 on EOF.
|
int |
read(byte[] buffer,
int offset,
int length)
Reads a buffer from a file, returning -1 on EOF.
|
int |
read(char[] buffer,
int offset,
int length)
Reads a buffer from a file, returning -1 on EOF.
|
StringValue |
read(int length)
Reads a Binary string.
|
StringValue |
readLine(long length)
Reads a line from the buffer.
|
boolean |
readOptionalLinefeed()
Reads the optional linefeed character from a \r\n
|
long |
seek(long offset,
int whence)
Seek according to offset and whence.
|
void |
setEncoding(java.lang.String encoding)
Sets the current read encoding.
|
boolean |
setPosition(long offset)
Sets the current location in the stream
|
Value |
stat()
Returns an array filled with stat information.
|
java.lang.String |
toString()
Converts to a string.
|
boolean |
unlock()
Unlock the advisory lock.
|
void |
unread()
Unread a character.
|
void |
write(byte[] buffer,
int offset,
int length)
Writes a buffer to a file.
|
void |
write(int ch)
Writes a buffer to a file.
|
getResourceType, writeclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitwritepublic FileInputOutput(Env env, Path path) throws java.io.IOException
java.io.IOExceptionpublic FileInputOutput(Env env, Path path, boolean append, boolean truncate) throws java.io.IOException
java.io.IOExceptionpublic java.io.OutputStream getOutputStream()
getOutputStream in interface BinaryOutputgetOutputStream in class AbstractBinaryOutputpublic java.io.InputStream getInputStream()
getInputStream in interface BinaryInputpublic int getAvailable()
throws java.io.IOException
getAvailable in interface BinaryInputjava.io.IOExceptionpublic Path getPath()
public void setEncoding(java.lang.String encoding)
throws java.io.UnsupportedEncodingException
encoding - name of the read encodingjava.io.UnsupportedEncodingExceptionpublic void unread()
throws java.io.IOException
unread in interface BinaryInputjava.io.IOExceptionpublic int read()
throws java.io.IOException
read in interface BinaryInputjava.io.IOExceptionpublic int read(byte[] buffer,
int offset,
int length)
throws java.io.IOException
read in interface BinaryInputjava.io.IOExceptionpublic int read(char[] buffer,
int offset,
int length)
throws java.io.IOException
java.io.IOExceptionpublic StringValue appendTo(StringValue builder) throws java.io.IOException
appendTo in interface BinaryInputjava.io.IOExceptionpublic StringValue read(int length) throws java.io.IOException
read in interface BinaryInputjava.io.IOExceptionpublic boolean readOptionalLinefeed()
throws java.io.IOException
readOptionalLinefeed in interface BinaryInputjava.io.IOExceptionpublic StringValue readLine(long length) throws java.io.IOException
readLine in interface BinaryInputjava.io.IOExceptionpublic boolean isEOF()
isEOF in interface BinaryStreamisEOF in class AbstractBinaryOutputpublic void print(char v)
throws java.io.IOException
print in interface BinaryOutputprint in class AbstractBinaryOutputjava.io.IOExceptionpublic void print(java.lang.String v)
throws java.io.IOException
print in interface BinaryOutputprint in class AbstractBinaryOutputjava.io.IOExceptionpublic void write(byte[] buffer,
int offset,
int length)
throws java.io.IOException
write in interface BinaryOutputwrite in class java.io.OutputStreamjava.io.IOExceptionpublic void write(int ch)
throws java.io.IOException
write in class java.io.OutputStreamjava.io.IOExceptionpublic void flush()
throws java.io.IOException
flush in interface BinaryOutputflush in interface java.io.Flushableflush in class AbstractBinaryOutputjava.io.IOExceptionpublic void closeWrite()
closeWrite in interface BinaryOutputcloseWrite in class AbstractBinaryOutputpublic void closeRead()
closeRead in interface BinaryInputpublic void close()
close in interface BinaryInputclose in interface BinaryOutputclose in interface BinaryStreamclose in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in class AbstractBinaryOutputpublic void cleanup()
cleanup in interface EnvCleanuppublic long getPosition()
getPosition in interface BinaryInputgetPosition in interface BinaryStreamgetPosition in class AbstractBinaryOutputpublic boolean setPosition(long offset)
setPosition in interface BinaryInputsetPosition in interface BinaryStreamsetPosition in class AbstractBinaryOutputpublic long seek(long offset,
int whence)
BinaryStreamseek in interface BinaryStreamseek in class AbstractBinaryOutputpublic BinaryInput openCopy() throws java.io.IOException
openCopy in interface BinaryInputjava.io.IOExceptionpublic boolean lock(boolean shared,
boolean block)
lock in interface LockableStreampublic boolean unlock()
unlock in interface LockableStreampublic Value stat()
BinaryStreamstat in interface BinaryStreamstat in class AbstractBinaryOutputpublic java.lang.String toString()
toString in class java.lang.Objectenv -