All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.caucho.vfs.package.html Maven / Gradle / Ivy

There is a newer version: 4.0.66
Show newest version


Resin's Virtual File System.  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)

Reading a File

ReadStream implements InputStream so it can be used wherever an InputStream is appropriate.

The Vfs facade is convenient for opening files.

ReadStream rs = Vfs.openRead("http://www.yahoo.com");
int ch;

while ((ch = rs.read()) >= 0)
  System.out.print((char) ch);

Writing a File

WriteStream implements OutputStream so it can be used wherever an OutputStream is appropriate. It also implements the familiar print() methods from PrintStream, although they do throw IOExceptions.

The Vfs facade is convenient for opening files.

WriteStream ws = Vfs.openWrite("mailto:[email protected]");
ws.setAttribute("subject", "hi, there");

ws.println("Just a little hello, world message");
ws.close();




© 2015 - 2024 Weber Informatics LLC | Privacy Policy