You can redirect the standard input and output of a script by calling the
setWriter methods of the script context. For example,
StringWriter writer = new StringWriter(); engine.getContext().setWriter(new PrintWriter(writer, true));
println functions is sent to
You can pass any
Writer to the
setWriter method, but the Rhino engine throws an exception if it is not a
setWriter methods only affect the scripting engine’s standard input and output sources. For example, if you ...