class SubFileWriter extends SubStoreWriter
StructuredFile. A sub-file
provides standard DataInput/DataOutput facilities, and takes care of
writing to the correct subset of the main StructuredFile.| Modifier and Type | Field and Description |
|---|---|
private byte[] |
buf
Buffered data (cuts down access to the physical file)
|
private static int |
BUF_SIZE
Size of the buffer to maintain
|
private int |
bufTop
Amount of data buffered
|
private RandomAccessFile |
file
Actual disk file to write to
|
private StructuredFile |
parent
The structured file that owns this Subfile
|
private long |
segOffset
Absolute file position for the subfile's start
|
private long |
writtenPos
Current write position within the subfile
|
| Constructor and Description |
|---|
SubFileWriter(RandomAccessFile file,
StructuredFile parent,
long segOffset)
Construct a subfile writer.
|
| Modifier and Type | Method and Description |
|---|---|
private void |
checkLength(int nBytes)
Ensure that the buffer has room for the specified number of bytes.
|
void |
close() |
long |
length() |
void |
write(byte[] b) |
void |
write(byte[] b,
int off,
int len) |
void |
writeByte(int v) |
void |
writeInt(int v) |
writeCharsprivate RandomAccessFile file
private StructuredFile parent
private long segOffset
private long writtenPos
private static final int BUF_SIZE
private byte[] buf
private int bufTop
SubFileWriter(RandomAccessFile file,
StructuredFile parent,
long segOffset)
throws IOException
file - Disk file to attach toparent - Structured file to attach tosegOffset - Beginning offset of the segmentIOExceptionpublic void close()
throws IOException
close in class SubStoreWriterIOExceptionpublic long length()
throws IOException
length in class SubStoreWriterIOExceptionprivate void checkLength(int nBytes)
throws IOException
nBytes - Amount of space desiredIOExceptionpublic void write(byte[] b)
throws IOException
write in class SubStoreWriterIOExceptionpublic void write(byte[] b,
int off,
int len)
throws IOException
write in class SubStoreWriterIOExceptionpublic void writeByte(int v)
throws IOException
writeByte in class SubStoreWriterIOExceptionpublic void writeInt(int v)
throws IOException
writeInt in class SubStoreWriterIOException