public interface StorageRandomAccessFile
extends java.io.DataInput, java.io.DataOutput
Each StorageRandomAccessFile has an associated file pointer, a byte offset in the file. All reading and writing takes place at the file pointer offset and advances it.
An implementation of StorageRandomAccessFile need not be thread safe. The database engine single-threads access to each StorageRandomAccessFile instance. Two threads will not access the same StorageRandomAccessFile instance at the same time.
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes this file.
|
long |
getFilePointer()
Get the current offset in this file.
|
long |
length()
Gets the length of this file.
|
int |
read(byte[] b,
int off,
int len)
Reads up to
len bytes of data from this file into an
array of bytes. |
void |
seek(long newFilePointer)
Set the file pointer.
|
void |
setLength(long newLength)
Sets the length of this file, either extending or truncating it.
|
void |
sync()
Force any changes out to the persistent store.
|
void close() throws java.io.IOException
java.io.IOException
- - if an I/O error occurs.long getFilePointer() throws java.io.IOException
java.io.IOException
- - if an I/O error occurs.long length() throws java.io.IOException
java.io.IOException
- - if an I/O error occurs.void seek(long newFilePointer) throws java.io.IOException
newFilePointer
- the new file pointer, measured in bytes from the beginning of the file.java.io.IOException
- - if newFilePointer is less than 0 or an I/O error occurs.void setLength(long newLength) throws java.io.IOException
If the file is extended then the contents of the extension are not defined.
If the file is truncated and the file pointer is greater than the new length then the file pointer is set to the new length.
newLength
- The new file length.java.io.IOException
- If an I/O error occurs.void sync() throws java.io.IOException
SyncFailedException
- if a possibly recoverable error occurs.java.io.IOException
- If an IO error occurs.int read(byte[] b, int off, int len) throws java.io.IOException
len
bytes of data from this file into an
array of bytes. This method blocks until at least one byte of input
is available.
b
- the buffer into which the data is read.off
- the start offset in array b
at which the data is written.len
- the maximum number of bytes read.-1
if there is no more data because the end of
the file has been reached.java.io.IOException
- If the first byte cannot be read for any reason
other than end of file, or if the random access file has been closed, or
if some other I/O error occurs.java.lang.NullPointerException
- If b
is null
.java.lang.IndexOutOfBoundsException
- If off
is negative,
len
is negative, or len
is greater than
b.length - off