public class StreamImpl
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
protected static NullPath |
_nullPath |
protected Path |
_path |
| Constructor and Description |
|---|
StreamImpl() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
canRead()
Returns true if this is a read stream.
|
boolean |
canWrite()
Returns true if this is a writable stream.
|
void |
clearWrite()
Clears any buffered values in the write.
|
void |
close()
Closes the stream.
|
void |
closeWrite()
Closes the write half of the stream.
|
void |
flush()
Flushes the write output.
|
void |
flushBuffer()
Flushes buffered writes.
|
void |
flushToDisk()
Flushes the write output, forcing to disk.
|
java.lang.Object |
getAttribute(java.lang.String name)
Returns a stream attribute.
|
java.util.Iterator<java.lang.String> |
getAttributeNames()
Returns an iterator of the attribute names.
|
int |
getAvailable()
Returns the number of bytes available without blocking.
|
boolean |
getFlushOnNewline()
Returns true if the buffer should be flushed on every newline.
|
byte[] |
getNewline()
Returns the stream's natural newline character.
|
Path |
getPath()
Returns the Path associated with the stream.
|
byte[] |
getReadBuffer()
Returns the read buffer.
|
long |
getReadPosition()
Returns the current read position of the underlying file.
|
boolean |
hasSkip()
Returns true if the stream implements skip.
|
boolean |
isClosed()
Returns true if the stream is closed.
|
boolean |
isEof() |
boolean |
isMmapEnabled()
Returns true if the stream supports mmap.
|
boolean |
isSendfileEnabled()
Returns true if the stream supports mmap.
|
int |
read(byte[] buffer,
int offset,
int length)
Reads the next chunk from the stream.
|
int |
readNonBlock(byte[] buffer,
int offset,
int length)
Reads the next chunk from the stream in non-blocking mode.
|
int |
readTimeout(byte[] buffer,
int offset,
int length,
long timeout)
Reads the next chunk from the stream in non-blocking mode.
|
void |
removeAttribute(java.lang.String name)
Removes a stream attribute.
|
void |
seekEnd(long offset)
Seeks based on the end.
|
void |
seekStart(long offset)
Seeks based on the start.
|
void |
setAttribute(java.lang.String name,
java.lang.Object value)
Sets a stream attribute.
|
void |
setPath(Path path)
Sets the Path associated with the stream.
|
void |
setWriteEncoding(java.lang.String encoding)
Sets the write encoding.
|
long |
skip(long n)
Skips a number of bytes, returning the bytes skipped.
|
void |
write(byte[] buffer,
int offset,
int length,
boolean isEnd)
Writes a buffer to the underlying stream.
|
boolean |
write(byte[] buf1,
int off1,
int len1,
byte[] buf2,
int off2,
int len2,
boolean isEnd)
Writes a pair of buffer to the underlying stream.
|
void |
writeMmap(long mmapAddress,
long[] mmapBlocks,
long mmapOffset,
long mmapLength) |
void |
writeSendfile(byte[] buffer,
int offset,
int length,
byte[] fileName,
int nameLength,
long fileLength) |
public byte[] getNewline()
public boolean hasSkip()
public long skip(long n)
throws java.io.IOException
n - the number of types to skip.java.io.IOExceptionpublic boolean canRead()
public byte[] getReadBuffer()
public int read(byte[] buffer,
int offset,
int length)
throws java.io.IOException
buffer - byte array receiving the data.offset - starting offset into the array.length - number of bytes to read.java.io.IOExceptionpublic int readNonBlock(byte[] buffer,
int offset,
int length)
throws java.io.IOException
buffer - byte array receiving the data.offset - starting offset into the array.length - number of bytes to read.java.io.IOExceptionpublic int readTimeout(byte[] buffer,
int offset,
int length,
long timeout)
throws java.io.IOException
buffer - byte array receiving the data.offset - starting offset into the array.length - number of bytes to read.java.io.IOExceptionpublic int getAvailable()
throws java.io.IOException
java.io.IOExceptionpublic boolean isEof()
throws java.io.IOException
java.io.IOExceptionpublic long getReadPosition()
public boolean canWrite()
public boolean getFlushOnNewline()
public void setWriteEncoding(java.lang.String encoding)
public void write(byte[] buffer,
int offset,
int length,
boolean isEnd)
throws java.io.IOException
buffer - 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.IOExceptionpublic boolean write(byte[] buf1,
int off1,
int len1,
byte[] buf2,
int off2,
int len2,
boolean isEnd)
throws java.io.IOException
buf1 - the byte array to write.off1 - the offset into the byte array.len1 - the number of bytes to write.buf2 - the byte array to write.off2 - the offset into the byte array.len2 - the number of bytes to write.isEnd - true when the write is flushing a close.java.io.IOExceptionpublic void clearWrite()
public void seekStart(long offset)
throws java.io.IOException
java.io.IOExceptionpublic void seekEnd(long offset)
throws java.io.IOException
java.io.IOExceptionpublic void flushBuffer()
throws java.io.IOException
java.io.IOExceptionpublic void flush()
throws java.io.IOException
java.io.IOExceptionpublic void flushToDisk()
throws java.io.IOException
java.io.IOExceptionpublic Path getPath()
public void setPath(Path path)
public java.lang.Object getAttribute(java.lang.String name)
throws java.io.IOException
name - the attribute name.java.io.IOExceptionpublic void setAttribute(java.lang.String name,
java.lang.Object value)
throws java.io.IOException
name - the attribute name.value - the attribute value.java.io.IOExceptionpublic void removeAttribute(java.lang.String name)
throws java.io.IOException
name - the attribute name.java.io.IOExceptionpublic java.util.Iterator<java.lang.String> getAttributeNames()
throws java.io.IOException
java.io.IOExceptionpublic boolean isMmapEnabled()
public boolean isSendfileEnabled()
public void writeMmap(long mmapAddress,
long[] mmapBlocks,
long mmapOffset,
long mmapLength)
throws java.io.IOException
java.io.IOExceptionpublic void writeSendfile(byte[] buffer,
int offset,
int length,
byte[] fileName,
int nameLength,
long fileLength)
throws java.io.IOException
java.io.IOExceptionpublic void closeWrite()
throws java.io.IOException
java.io.IOExceptionpublic boolean isClosed()
public void close()
throws java.io.IOException
java.io.IOException