About

TrueVFS Access features the primary API for TrueVFS applications. It provides simple, uniform, transparent, thread-safe, read/write access to archive files as if they were just virtual directories in a file system path.

Technically, this module is just a facade for the module TrueVFS Kernel so that you can exploit its features via a simple, yet powerful API. As an implication, no file system state is managed by this module - this is the job of the TrueVFS Kernel modules.

The TFile* classes

The TFile* classes mimick or extend the File* classes of the package java.io, so that you can use them with a minimal learning curve or - where they actually extend a File* class - even use them as polymorphic replacements for their super class.

In contrast to the TPath class however (see below), these classes are constrained to access the platform file system and any archive files within the platform file system.

For example, an application could access an entry within an archive file using a TFile like this:

File entry = new TFile("archive.zip/dir/HälloWörld.txt");
try (Writer writer = new TFileWriter(entry)) {
    writer.write("Hello world!\n");
}

This example presumes that the JARs of the driver modules TrueVFS Driver FILE and TrueVFS Driver ZIP are present on the class path at run time.

For the API documentation, please refer to the Javadoc of the package net.truevfs.access

The TPath class et al

Like the TFile* classes, the TPath class provides simple, uniform, transparent, thread-safe, read/write access to archive files as if they were virtual directories in a file system path. It's accompanied by the TFileSystem and TFileSystemProvider classes to implement a file system provider for the NIO.2 API (JSR 203) of JSE 7.

In contrast to the TFile* classes however, the TPath class can get used to access any (virtual) file system, not just the platform file system and any archive files within the platform file system.

For example, an application could access an entry within an archive file which is located at a web site using a TPath like this:

Path path = new TPath(new URI("http://acme.com/download/everything.tar.gz/README.TXT"));
try (InputStream in = Files.newInputStream(path)) {
    // Read archive entry contents here.
    ...
}

This example presumes that the JARs of the driver modules TrueVFS Driver HTTP(S) and TrueVFS Driver TAR are present on the class path at run time.

For the API documentation, please refer to the Javadoc of the package net.java.truevfs.access

More Examples

For more examples, please use the Maven archetype for TrueVFS Access applications as described in the Kick-Starting TrueVFS section. You might also want to download the source code of the module TrueVFS Samples.