Save This Page
Home » db-derby-10.5.3.0 » org.apache.derby.io » [javadoc | source]
org.apache.derby.io
public interface: StorageRandomAccessFile [javadoc | source]

All Implemented Interfaces:
    DataOutput, DataInput

All Known Implementing Classes:
    VirtualRandomAccessFile, DirRandomAccessFile, DirRandomAccessFile4

This interface abstracts an object that implements reading and writing on a random access file. It extends DataInput and DataOutput, so it implicitly contains all the methods of those interfaces. Any method in this interface that also appears in the java.io.RandomAccessFile class should behave as the java.io.RandomAccessFile method does.

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.

Method from org.apache.derby.io.StorageRandomAccessFile Summary:
close,   getFilePointer,   length,   read,   seek,   setLength,   sync
Method from org.apache.derby.io.StorageRandomAccessFile Detail:
 public  void close() throws IOException
    Closes this file.
 public long getFilePointer() throws IOException
    Get the current offset in this file.
 public long length() throws IOException
    Gets the length of this file.
 public int read(byte[] b,
    int off,
    int len) throws IOException
    Reads up to len bytes of data from this file into an array of bytes. This method blocks until at least one byte of input is available.

 public  void seek(long newFilePointer) throws IOException
    Set the file pointer. It may be moved beyond the end of the file, but this does not change the length of the file. The length of the file is not changed until data is actually written..
 public  void setLength(long newLength) throws IOException
    Sets the length of this file, either extending or truncating it.

    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.

 public  void sync(boolean metaData) throws IOException
    Force any changes out to the persistent store. If the database is to be transient, that is, if the database does not survive a restart, then the sync method implementation need not do anything.