Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

This post is motivated by this question on R-help. This is a simple java class that sends files through Rserve using the classes RFileInputStream and RFileOutputStream

Then we create a simple file on the client machine:

$cat > testfile.txt bla bla ^C  And we are good to go: $ javac -cp .:REngine.jar:Rserve.jar RserveWire.java
$java -cp .:REngine.jar:Rserve.jar RserveWire testfile.txt serverfile.txt /tmp/Rserv/conn6 writing the client file 'testfile.txt' to the server as 'serverfile.txt' writing the server file 'file.txt' to the client as 'file.txt'  Now in the directory /tmp/Rserv/conn6 of the server, there are the files “serverfile.txt” and “file.txt” $ cat serverfile.txt
bla bla
$cat file.txt [1] -1.16541741 -0.55857285 2.19752036 -0.78432188 1.40739981 -0.87252966 [7] -0.11545651 -0.36735874 -2.75736666 0.29798096 -0.86836355 -0.03416198 [13] -0.44344089 0.88976360 0.58821334 -0.10354205 -0.88760475 -0.64608338 [19] 0.96552319 -1.57166441 -0.19010633 -1.42239696 0.49363257 0.06167547 [25] 0.34801546 -0.41211734 -0.20320050 -1.45370497 1.34383425 -0.89461504  and on the client there is also the “file.txt” $ cat file.txt
[1] -1.16541741 -0.55857285  2.19752036 -0.78432188  1.40739981 -0.87252966
[7] -0.11545651 -0.36735874 -2.75736666  0.29798096 -0.86836355 -0.03416198
[13] -0.44344089  0.88976360  0.58821334 -0.10354205 -0.88760475 -0.64608338
[19]  0.96552319 -1.57166441 -0.19010633 -1.42239696  0.49363257  0.06167547
[25]  0.34801546 -0.41211734 -0.20320050 -1.45370497  1.34383425 -0.89461504