caucho
 VFS Introduction


Resin's VFS combines and simplifies the morass in Java I/O. The core classes are:

  • Path - API similar to File, but supports URLs as well as paths.
  • ReadStream - buffered read stream handing both byte and character input
  • WriteStream - buffered write stream handling both byte and character output

Virtual Paths

Path access is based on standard URLs. The following URL schemes are predefined.

  • file: -- the standard filesystem
  • http: -- the http filesystem
  • mailto: -- sending mail
  • stdout: -- standard output (System.out)
  • stderr: -- standard error (System.err)
  • tcp: -- TCP socket pair
  • null: -- /dev/null
  • log: -- debug logging (controlled by resin.conf)

ReadStream and WriteStream

Since ReadStream implements InputStream and WriteStream implements OutputStream the VFS streams can be used without fuss in most cases.

The VFS streams are always buffered, so applications don't need to worry about creating buffered streams.

WriteStream also implements the print() functions, throwing IOExceptions, so applications can easily write strings.

Vfs Facade

The Vfs facade is the most convenient way to open a new file using Resin's VFS. To open a file for reading, use

ReadStream is = Vfs.openRead("test.html");


Copyright © 1998-2002 Caucho Technology, Inc. All rights reserved.
Resin® is a registered trademark, and HardCoretm and Quercustm are trademarks of Caucho Technology, Inc.