Commons VFS directly supports the following file systems with the listed capabilities:
| File System | Directory Contents | Authentication | Read | Write | Create/Delete | Random | Version | Rename |
|---|---|---|---|---|---|---|---|---|
| BZIP2 | No | No | Yes | Yes | No | No | No | No |
| File | No | No | Yes | Yes | Yes | Read/Write | No | Yes |
| FTP | No | Yes | Yes | Yes | Yes | Read | No | Yes |
| FTPS | No | Yes | Yes | Yes | Yes | Read | No | Yes |
| GZIP | No | No | Yes | Yes | No | No | No | No |
| HTTP | Yes | Yes | Yes | No | No | Read | No | No |
| HTTPS | Yes | Yes | Yes | No | No | Read | No | No |
| Jar | No | No | Yes | No | No | No | No | No |
| RAM | No | No | Yes | Yes | Yes | Read/Write | No | Yes |
| RES | No | No | Yes | Yes | Yes | Read/Write | No | Yes |
| SFTP | No | Yes | Yes | Yes | Yes | Read | No | Yes |
| Tar | No | No | Yes | No | No | No | No | No |
| Temp | No | No | Yes | Yes | Yes | Read/Write | No | Yes |
| WebDAV | Yes | Yes | Yes | Yes | Yes | Read/Write | Yes | Yes |
| Zip | No | No | Yes | No | No | No | No | No |
The following file systems are in development:
| File System | Directory Contents | Authentication | Read | Write | Create/Delete | Random | Version | Rename |
|---|---|---|---|---|---|---|---|---|
| CIFS | No | Yes | Yes | Yes | Yes | Read/Write | No | Yes |
| mime | No | No | Yes | No | No | No | No | No |
All filenames are treated as URIs. One of the consequences of this is you have to encode the '%'
character using %25.
Depending on the filesystem additional characters are encoded if needet. This is done automatically, but
might be reflected in the filename.
Examples
Many file systems accept a userid and password as part of the url. However, storing a password in clear text in a file is usually unacceptable. To help with that Commons VFS provides a mechanism to encrypt the password. It should be noted though, that this is not completely secure since the password needs to be unencrypted before Commons VFS can use it.
To create an encrypted password do:
java -cp commons-vfs-2.0.jar org.apache.commons.vfs2.util.EncryptUtil encrypt mypasswordwhere mypassword is the password you want to encrypt. The result of this will be a single line of output containing uppercase hex characters. For example,
java -cp commons-vfs-2.0.jar org.apache.commons.vfs2.util.EncryptUtil encrypt WontUBee9 D7B82198B272F5C93790FEB38A73C7B8Then cut the output returned and paste it into the URL as:
https://testuser:{D7B82198B272F5C93790FEB38A73C7B8}@myhost.com/svn/repos/vfstest/trunkVFS treats a password enclosed in {} as being encrypted and will decrypt the password before using it.
Provides access to the files on the local physical file system.
URI Format
[file://] absolute-path
Where absolute-path is a valid absolute file name for the local platform. UNC names are supported under Windows.
Examples
Provides read-only access to the contents of Zip, Jar and Tar files.
URI Format
zip:// arch-file-uri[! absolute-path]
jar:// arch-file-uri[! absolute-path]
tar:// arch-file-uri[! absolute-path]
tgz:// arch-file-uri[! absolute-path]
tbz2:// arch-file-uri[! absolute-path]
Where
arch-file-uri refers to a file of any
supported type, including other zip files. Note: if you would like
to use the ! as normal character it must be escaped
using %21.
tgz and tbz2 are convenience for tar:gz and tar:bz2.
Examples
Provides read-only access to the contents of gzip and bzip2 files.
URI Format
gz:// compressed-file-uri
bz2:// compressed-file-uri
Where compressed-file-uri refers to a file of any supported type. There is no need to add a ! part to the uri if you read the content of the file you always will get the uncompressed version.
Examples
Provides access to files on an HTTP server.
URI Format
http://[ username[: password]@] hostname[: port][ absolute-path]
https://[ username[: password]@] hostname[: port][ absolute-path]
File System Options
Examples
Provides access to files on a WebDAV server.
URI Format
webdav://[ username[: password]@] hostname[: port][ absolute-path]
File System Options
Examples
Provides access to the files on an FTP server.
URI Format
ftp://[ username[: password]@] hostname[: port][ absolute-path]
Examples
Provides access to the files on an FTP server over SSL.
URI Format
ftps://[ username[: password]@] hostname[: port][ absolute-path]
Examples
Provides access to the files on an SFTP server (that is, an SSH or SCP server).
URI Format
sftp://[ username[: password]@] hostname[: port][ absolute-path]
Examples
Provides access to the files on a CIFS server, such as a Samba server, or a Windows share.
URI Format
smb://[ username[: password]@] hostname[: port][ absolute-path]
Examples
Provides access to a temporary file system, or scratchpad, that is deleted when Commons VFS shuts down. The temporary file system is backed by a local file system.
URI Format
tmp://[ absolute-path]
Examples
This is not really a filesystem, it just tries to lookup a resource using javas ClassLoader.getResource() and creates a VFS url for further processing.
URI Format
res://[ path]
Examples
A filesystem which stores all the data in memory. You can configure the max size and a predicate (FileSelector). The predicate will be used to check if it is allowed to add a given file.
URI Format
ram://[ path]
Examples
This filesystem can read mails and its attachements like archives.
If a part in the parsed mail has no name, a dummy name will be generated.
The dummy name is: _body_part_X where X will be replaced by the part number.
URI Format
mime:// mime-file-uri[! absolute-path]
Examples