Using RandomAccessFile to access data which doesn’t come from a local file.
Some libraries and applications rely on a RandomAccessFile instance to process its IO tasks, and thus are usually limited to access data from a local file.
If an application needs to access data from another source (from an SFTP file, an HTTP file, CIFS-accessible file, a file inside a zip, tar, gzip or bzip2 archive, etc), it has to use another algorithm - the process isn’t transparent.
Such application could be benefited by an adapter class providing a “RandomAccessFile” view of arbitrary data sources, allowing it to transparently access data from different sources.
Example: a database server using a RandomAccessFile instance to access its data from a local file would automatically be able to access it from a gzip-compressed file.
RACRandomAccessFile is such an adapter class; by leveraging Commons-VFS and the file systems it provides, it allows you to use any RandomAccessContent instance as if it were a RandomAccessFile instance.
And it’s easy to use. See the usage example below:
on June 20th, 2007 at 4:42 pm
Really just an aside but databases can often be a special case. There are many things they can require of their filesystems such as being able to lock a file region (or a whole file) which mightn’t be supported for example on networked filesystems or compressed files.
Best,
Dan.