Example usage for java.io FileReader toString

List of usage examples for java.io FileReader toString

Introduction

In this page you can find the example usage for java.io FileReader toString.

Prototype

public String toString() 

Source Link

Document

Returns a string representation of the object.

Usage

From source file:org.jaggeryjs.jaggery.tools.JaggeryShell.java

/**
 * Evaluate JavaScript source.//from   www .  jav  a  2 s.co m
 *
 * @param cx the current context
 * @param filename the name of the file to compile, or null
 *                 for interactive mode.
 */
@SuppressWarnings("unused")
private void processSource(Context cx, String filename) {
    if (filename == null) {
        processSource(cx);
    } else {

        final String fileSeparator = System.getProperty("file.separator");
        String fileToProcess = filename.replace("\\", fileSeparator + fileSeparator);
        fileToProcess = fileToProcess.replace("/", fileSeparator + fileSeparator);

        FileReader in = null;
        try {
            in = new FileReader(fileToProcess);
            in.toString();
        } catch (FileNotFoundException ex) {
            Context.reportError("Couldn't open file \"" + fileToProcess + "\".");
            return;
        } finally {
            try {
                in.close();
            } catch (IOException e) {
                LOG.error("Error closing file reader for file " + filename, e);
            }

        }

        CommandLineExecutor.parseJaggeryScript(fileToProcess);
    }
}