Search in sources :

Example 1 with GroovyPrintWriter

use of groovy.io.GroovyPrintWriter in project groovy by apache.

the class DefaultGroovyMethods method println.

/**
 * Print a linebreak to the standard output stream.
 *
 * @param self any Object
 * @since 1.0
 */
public static void println(Object self) {
    // we won't get here if we are a PrintWriter
    if (self instanceof Writer) {
        PrintWriter pw = new GroovyPrintWriter((Writer) self);
        pw.println();
    } else {
        System.out.println();
    }
}
Also used : GroovyPrintWriter(groovy.io.GroovyPrintWriter) StringBuilderWriter(org.apache.groovy.io.StringBuilderWriter) PrintWriter(java.io.PrintWriter) GroovyPrintWriter(groovy.io.GroovyPrintWriter) Writer(java.io.Writer) PrintWriter(java.io.PrintWriter) GroovyPrintWriter(groovy.io.GroovyPrintWriter)

Example 2 with GroovyPrintWriter

use of groovy.io.GroovyPrintWriter in project groovy-core by groovy.

the class DefaultGroovyMethods method println.

/**
 * Print a value formatted Groovy style (followed by a newline) to self
 * if it is a Writer, otherwise to the standard output stream.
 *
 * @param self  any Object
 * @param value the value to print
 * @since 1.0
 */
public static void println(Object self, Object value) {
    // we won't get here if we are a PrintWriter
    if (self instanceof Writer) {
        final PrintWriter pw = new GroovyPrintWriter((Writer) self);
        pw.println(value);
    } else {
        System.out.println(InvokerHelper.toString(value));
    }
}
Also used : GroovyPrintWriter(groovy.io.GroovyPrintWriter) GroovyPrintWriter(groovy.io.GroovyPrintWriter) GroovyPrintWriter(groovy.io.GroovyPrintWriter)

Aggregations

GroovyPrintWriter (groovy.io.GroovyPrintWriter)2 PrintWriter (java.io.PrintWriter)1 Writer (java.io.Writer)1 StringBuilderWriter (org.apache.groovy.io.StringBuilderWriter)1