RMIStreams is a small but yet useful project that I developed quickly when I was working on RFS.

I remember I got this somewhere on the web but I don't remember where... anyway.

The purpose is to provide a transparent and convenient implementation of Java InputStreams and OutputStreams over RMI, so that you can transfer data easily between Java applications, using regular streams.

Example of use

The following code snippet shows how to downoad a file using RMIStreams.

Server-side

On the server, we create an instance of the RMIInputStream to be obtained by a remote client. For the sake of simplicity, we'll put the object in the RMI Registry, which is of course a bad idea in real-life (you should instead return it from a server object method).

// create a regular IS on a local file
 FileInputStream fis = new FileInputStream(fileName);
 // wrap it into a RMIInputStream
 RMIInputStream ris = new RMIInputStreamImpl(fis);
 // put it it in the registry
 Naming.rebind("myInputStream", risImpl);
}

Client-side

The client gets hold of the remote stream and wraps it into a local object that acts as a local proxy :

// get hold of the server object...
 RMIInputStream ris = ... ;
 // wrap it into a local "proxy" (this one implements java.io.InputStream)
 InputStream is = new RemoteInputStream(ris);
 // use the stream as usual...
 is.xxx();

NOTE
We've only described one part of RMIStreams here : you can also have RemoteOutputStreams !

Download

Download the full project there (contains Eclipse .project and ant script) :

Attach:RMIStreams.zip

For any questions, remarks etc., email me (remi "at" rvkb.com) !