public class OffheapOutputStream extends SeekableOutputStream
Each file is made up of multiple blocks of size BLOCK_SIZE. There are two pointers to track the writes:
currentBufferIndex tracks the block number which should be written to.
currentBuffer is the actual block to which the bytes are written. It is a simple
ByteBuffer.
The actual position at which the next byte is written, from the beginning of the file is:
(currentBufferIndex * BLOCK_SIZE) + currentBuffer.position()
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
void |
flush() |
long |
getFilePointer()
Returns the current offset in this file.
|
long |
length()
Returns the length of the stream.
|
void |
reset()
Resets this to an empty file.
|
void |
seek(long pos)
Sets the file-pointer offset, measured from the beginning of this file, at which the next write occurs.
|
long |
sizeInBytes()
Returns byte usage of all buffers.
|
String |
toString() |
void |
write(byte[] b,
int offset,
int len) |
void |
write(int b) |
writepublic void write(int b)
throws IOException
SeekableOutputStreamwrite in class SeekableOutputStreamIOExceptionpublic void write(byte[] b,
int offset,
int len)
throws IOException
write in class OutputStreamIOExceptionpublic void reset()
throws IOException
reset in class SeekableOutputStreamIOExceptionpublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in class OutputStreamIOExceptionpublic void seek(long pos)
throws IOException
SeekableOutputStreamseek in class SeekableOutputStreampos - - the offset position, measured in bytes from the beginning of the file, at which to set the file
pointer.IOException - if pos is less than 0 or if an I/O error occurs.public long length()
throws IOException
SeekableOutputStreamlength in class SeekableOutputStreamIOExceptionpublic void flush()
throws IOException
flush in interface Flushableflush in class OutputStreamIOExceptionpublic long getFilePointer()
SeekableOutputStreamgetFilePointer in class SeekableOutputStreampublic long sizeInBytes()
Copyright © 2015–2024. All rights reserved.