Example usage for javax.script ScriptContext getReader

List of usage examples for javax.script ScriptContext getReader

Introduction

In this page you can find the example usage for javax.script ScriptContext getReader.

Prototype

public Reader getReader();

Source Link

Document

Returns a Reader to be used by the script to read input.

Usage

From source file:Main.java

public static void main(String[] args) throws Exception {
    ScriptContext ctx = new SimpleScriptContext();

    // Get the reader and writers from the script context
    Reader inputReader = ctx.getReader();
    Writer outputWriter = ctx.getWriter();
    Writer errWriter = ctx.getErrorWriter();

    // Write all script outputs to an out.txt file
    Writer fileWriter = new FileWriter("out.txt");
    ctx.setWriter(fileWriter);/*from  www  .j  a va2s. c  o m*/
}