public class JniFileStream extends StreamImpl implements LockableStream
_nullPath, _path
Constructor and Description |
---|
JniFileStream(int fd,
boolean canRead,
boolean canWrite)
Create a new JniStream based on the java.io.* stream.
|
Modifier and Type | Method and Description |
---|---|
boolean |
canRead()
Returns true if this is a read stream.
|
boolean |
canWrite()
Returns true if this is a writeable stream.
|
void |
close()
Closes the stream.
|
protected void |
finalize() |
void |
flush()
Flushes the write output.
|
void |
flushToDisk()
Flushes the write output, forcing to disk.
|
int |
getAvailable()
Returns the number of bytes available without blocking.
|
static java.lang.Throwable |
getDisableCause() |
boolean |
hasSkip()
Returns true if the stream implements skip.
|
static boolean |
isEnabled() |
boolean |
lock(boolean shared,
boolean block)
Implement LockableStream as a no-op, but maintain
compatibility with FileWriteStream and FileReadStream
wrt returning false to indicate error case.
|
static JniFileStream |
openRead(byte[] name,
int length) |
static JniFileStream |
openWrite(byte[] name,
int length,
boolean isAppend) |
int |
read(byte[] buf,
int offset,
int length)
Reads data from the file.
|
void |
seekEnd(long offset)
Seeks based on the end.
|
void |
seekStart(long offset)
Seeks based on the start.
|
long |
skip(long length)
Skips a number of bytes, returning the bytes skipped.
|
java.lang.String |
toString()
Returns the debug name for the stream.
|
boolean |
unlock()
Unlock the advisory lock.
|
void |
write(byte[] buf,
int offset,
int length,
boolean isEnd)
Writes data to the file.
|
clearWrite, closeWrite, flushBuffer, getAttribute, getAttributeNames, getFlushOnNewline, getNewline, getPath, getReadBuffer, getReadPosition, isClosed, isEof, isMmapEnabled, isSendfileEnabled, readNonBlock, readTimeout, removeAttribute, setAttribute, setPath, setWriteEncoding, write, writeMmap, writeSendfile
public JniFileStream(int fd, boolean canRead, boolean canWrite)
public static boolean isEnabled()
public static java.lang.Throwable getDisableCause()
public static JniFileStream openRead(byte[] name, int length)
public static JniFileStream openWrite(byte[] name, int length, boolean isAppend)
public boolean canRead()
StreamImpl
canRead
in class StreamImpl
public boolean hasSkip()
StreamImpl
hasSkip
in class StreamImpl
public long skip(long length) throws java.io.IOException
StreamImpl
skip
in class StreamImpl
length
- the number of types to skip.java.io.IOException
public int read(byte[] buf, int offset, int length) throws java.io.IOException
read
in class StreamImpl
buf
- byte array receiving the data.offset
- starting offset into the array.length
- number of bytes to read.java.io.IOException
public int getAvailable() throws java.io.IOException
StreamImpl
getAvailable
in class StreamImpl
java.io.IOException
public boolean canWrite()
canWrite
in class StreamImpl
public void write(byte[] buf, int offset, int length, boolean isEnd) throws java.io.IOException
write
in class StreamImpl
buf
- the byte array to write.offset
- the offset into the byte array.length
- the number of bytes to write.isEnd
- true when the write is flushing a close.java.io.IOException
public void seekStart(long offset) throws java.io.IOException
StreamImpl
seekStart
in class StreamImpl
java.io.IOException
public void seekEnd(long offset) throws java.io.IOException
StreamImpl
seekEnd
in class StreamImpl
java.io.IOException
public void flush() throws java.io.IOException
StreamImpl
flush
in class StreamImpl
java.io.IOException
public void flushToDisk() throws java.io.IOException
StreamImpl
flushToDisk
in class StreamImpl
java.io.IOException
public void close() throws java.io.IOException
StreamImpl
close
in class StreamImpl
java.io.IOException
protected void finalize() throws java.io.IOException
finalize
in class java.lang.Object
java.io.IOException
public boolean lock(boolean shared, boolean block)
lock
in interface LockableStream
public boolean unlock()
LockableStream
unlock
in interface LockableStream
public java.lang.String toString()
toString
in class java.lang.Object