private void setOutputStream(PrintStream pstream) {
if (pstream == null) {
return;
}
Ruby runtime = provider.getRuntime();
RubyIO io = new RubyIO(runtime, pstream);
io.getOpenFile().getMainStream().setSync(true);
runtime.defineVariable(new OutputGlobalVariable(runtime, "$stdout", io));
runtime.getObject().getConstantMapForWrite().put("STDOUT", io);
runtime.getGlobalVariables().alias("$>", "$stdout");
runtime.getGlobalVariables().alias("$defout", "$stdout");
}