org.rosuda.REngine.Rserve
Class RFileInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by org.rosuda.REngine.Rserve.RFileInputStream
All Implemented Interfaces:
java.io.Closeable

public class RFileInputStream
extends java.io.InputStream

RFileInputStream is an InputStream to transfer files from Rserve server to the client. It is used very much like a FileInputStream. Currently mark and seek is not supported. The current implementation is also "one-shot" only, that means the file can be read only once.

Version:
$Id: RFileInputStream.java 2743 2007-05-04 16:42:17Z urbanek $

Method Summary
 void close()
          close stream - is not related to the actual RConnection, calling close does not close the RConnection
 int read()
          reads one byte from the file.
 int read(byte[] b, int off, int len)
          Reads specified number of bytes (or less) from the remote file.
 
Methods inherited from class java.io.InputStream
available, mark, markSupported, read, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

read

public int read()
         throws java.io.IOException
reads one byte from the file. This function should be avoided, since RFileInputStream provides no buffering. This means that each call to this function leads to a complete packet exchange between the server and the client. Use read(byte[],int,int) instead whenever possible. In fact this function calls #read(b,0,1).

Specified by:
read in class java.io.InputStream
Returns:
-1 on any failure, or the acquired byte (0..255) on success
Throws:
java.io.IOException

read

public int read(byte[] b,
                int off,
                int len)
         throws java.io.IOException
Reads specified number of bytes (or less) from the remote file.

Overrides:
read in class java.io.InputStream
Parameters:
b - buffer to store the read bytes
off - offset where to strat filling the buffer
len - maximal number of bytes to read
Returns:
number of bytes read or -1 if EOF reached
Throws:
java.io.IOException

close

public void close()
           throws java.io.IOException
close stream - is not related to the actual RConnection, calling close does not close the RConnection

Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.io.InputStream
Throws:
java.io.IOException