Java RMI Question -- How to write to a stream on the cleint side?

statik213

Golden Member
Oct 31, 2004
1,654
0
0
Not sure if there are any RMI gurus here but anyway her goes.

I need to transfer files from the (RMI) server to the client application per client requests. Streams in Java aren't serializeable so I can't just simply pass an inputstream from the client to the server to ask for the file to be written to.

I need to get this effect:

Call on client side:
someRMIServerInstance.writeFileToStream("Some File On The Server", someFileOutputStreamOnClientSide);

server side:
SomeRMIServer{
void writeFileToStream(String file, OutputStream ostream) throws RemoteException{
InputStream istream;
//
// set istream to read `file`
//
while(istream.available() > 0 ){
ostream.write(istream.read);
}
}
}

Any Ideas on how to get his effect using RMI? I'm using RMI for other things right now and am not too keen on writing code for sockets just for this one feature.