alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Groovy example source code file (GroovyPrintStream.java)

This example Groovy source code file (GroovyPrintStream.java) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Groovy tags/keywords

filenotfoundexception, filenotfoundexception, groovyprintstream, groovyprintstream, io, printstream, string, string, unsupportedencodingexception, unsupportedencodingexception

The Groovy GroovyPrintStream.java source code

/*
 * Copyright 2009 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package groovy.io;

import java.io.File;
import java.io.OutputStream;
import java.io.PrintStream;
import java.io.FileNotFoundException;
import java.io.UnsupportedEncodingException;

import org.codehaus.groovy.runtime.InvokerHelper;

/**
 * A PrintStream that outputs objects in Groovy style.
 * That means print(Object) uses InvokerHelper.toString(Object)
 * to produce the same results as Writer.print(Object).
 *
 * @author Jim White
 * @since 1.6
 */
public class GroovyPrintStream extends PrintStream
{
    /**
     * Creates a new print stream.  This stream will not flush automatically.
     *
     * @see java.io.PrintStream#PrintStream(java.io.OutputStream)
     */
    public GroovyPrintStream(OutputStream out) {
        super(out, false);
    }

    /**
     * Creates a new print stream.
     *
     * @see java.io.PrintStream#PrintStream(java.io.OutputStream, boolean)
     */
    public GroovyPrintStream(OutputStream out, boolean autoFlush) {
        super(out, autoFlush);
    }

    /**
     * Creates a new print stream.
     *
     * @see java.io.PrintStream#PrintStream(java.io.OutputStream, boolean, String)
     */
    public GroovyPrintStream(OutputStream out, boolean autoFlush, String encoding)
        throws UnsupportedEncodingException
    {
        super(out, autoFlush, encoding);
    }

    /**
     * Creates a new print stream, without automatic line flushing, with the
     * specified file name.
     *
     * @see java.io.PrintStream#PrintStream(String)
     */
    public GroovyPrintStream(String fileName) throws FileNotFoundException {
        super(fileName);
    }

    /**
     * Creates a new print stream, without automatic line flushing, with the
     * specified file name and charset. 
     *
     * @see java.io.PrintStream#PrintStream(String, String)
     */
    public GroovyPrintStream(String fileName, String csn)
        throws FileNotFoundException, UnsupportedEncodingException
    {
        super(fileName, csn);
    }

    /**
     * Creates a new print stream, without automatic line flushing, with the
     * specified file. 
     *
     * @see java.io.PrintStream#PrintStream(File)
     */
    public GroovyPrintStream(File file) throws FileNotFoundException {
        super(file);
    }

    /**
     * Creates a new print stream, without automatic line flushing, with the
     * specified file and charset. 
     *
     * @see java.io.PrintStream#PrintStream(File, String)
     */
    public GroovyPrintStream(File file, String csn)
        throws FileNotFoundException, UnsupportedEncodingException
    {
        super(file, csn);
    }

    /**
     * Prints an object Groovy style.
     *
     * @param      obj   The <code>Object to be printed
     */
    public void print(Object obj) {
        print(InvokerHelper.toString(obj));
    }

    /**
     * Prints an object Groovy style followed by a newline.  
     *
     * @param      obj   The <code>Object to be printed
     */
    public void println(Object obj) {
        println(InvokerHelper.toString(obj));
    }

}

Other Groovy examples (source code examples)

Here is a short list of links related to this Groovy GroovyPrintStream.java source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.