org.rosuda.JRI
Class RConsoleOutputStream
java.lang.Object
java.io.OutputStream
org.rosuda.JRI.RConsoleOutputStream
- All Implemented Interfaces:
- java.io.Closeable, java.io.Flushable
public class RConsoleOutputStream
- extends java.io.OutputStream
RConsoleOutputStream provides an OutputStream which causes its output to be written to the R console. It is a pseudo-stream as there is no real descriptor connected to the R console and thusly it is legal to have multiple console streams open. The synchonization happens at the RNI level.
Note that stdout/stderr are not connected to the R console by default, so one way of using this stream is to re-route Java output to R console:
System.setOut(new PrintStream(new RConsoleOutputStream(engine, 0)));
System.setErr(new PrintStream(new RConsoleOutputStream(engine, 1)));
- Since:
- JRI 0.4-0
Method Summary |
void |
close()
|
void |
write(byte[] b)
|
void |
write(byte[] b,
int off,
int len)
|
void |
write(int b)
|
Methods inherited from class java.io.OutputStream |
flush |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
RConsoleOutputStream
public RConsoleOutputStream(Rengine eng,
int oType)
- opens a new output stream to R console
- Parameters:
eng
- R engineoType
- output type (0=regular, 1=error/warning)
write
public void write(byte[] b,
int off,
int len)
throws java.io.IOException
- Overrides:
write
in class java.io.OutputStream
- Throws:
java.io.IOException
write
public void write(byte[] b)
throws java.io.IOException
- Overrides:
write
in class java.io.OutputStream
- Throws:
java.io.IOException
write
public void write(int b)
throws java.io.IOException
- Specified by:
write
in class java.io.OutputStream
- Throws:
java.io.IOException
close
public void close()
throws java.io.IOException
- Specified by:
close
in interface java.io.Closeable
- Overrides:
close
in class java.io.OutputStream
- Throws:
java.io.IOException