Package: groovy.io

## [Java] Class GroovyPrintWriter

- groovy.io.GroovyPrintWriter

-     public class GroovyPrintWriter
      extends PrintWriter

  A PrintWriter that outputs objects in Groovy style. That means print(Object) uses InvokerHelper.toString(Object) to produce the same results as Writer.print(Object).

  Since:
    1.6

- - ### Constructor Summary

    Constructors
    Constructor and description
    `GroovyPrintWriter(File file)` Creates a writer for the supplied file.
    `GroovyPrintWriter(File file, String csn)` Creates a writer for the supplied file using the given charset name.
    `GroovyPrintWriter(Writer out)` Creates a writer that delegates to the supplied writer.
    `GroovyPrintWriter(Writer out, boolean autoflush)` Creates a writer that delegates to the supplied writer.
    `GroovyPrintWriter(OutputStream out)` Creates a writer for the supplied output stream.
    `GroovyPrintWriter(OutputStream out, boolean autoflush)` Creates a writer for the supplied output stream.
    `GroovyPrintWriter(String filename)` Creates a writer for the supplied file name.
    `GroovyPrintWriter(String filename, String csn)` Creates a writer for the supplied file name using the given charset name.

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public void` | `print(Object x)` Prints an object using Groovy formatting.
    `` | `public void` | `println(Object x)` Prints an object followed by a line separator using Groovy formatting.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class PrintWriter` | `append, append, append, append, append, append, append, append, append, checkError, close, equals, flush, format, format, getClass, hashCode, notify, notifyAll, nullWriter, print, print, print, print, print, print, print, print, print, printf, printf, println, println, println, println, println, println, println, println, println, println, toString, wait, wait, wait, write, write, write, write, write`

- - ### Constructor Detail

    - #### public GroovyPrintWriter(File file)

      Creates a writer for the supplied file.

      throws:
        FileNotFoundException if the file cannot be opened
      Parameters:
        `file` - the target file

    - #### public GroovyPrintWriter(File file, String csn)

      Creates a writer for the supplied file using the given charset name.

      throws:
        FileNotFoundException if the file cannot be opened
      throws:
        UnsupportedEncodingException if the charset is unsupported
      Parameters:
        `file` - the target file
        `csn` - the charset name

    - #### public GroovyPrintWriter(Writer out)

      Creates a writer that delegates to the supplied writer.

      Parameters:
        `out` - the underlying writer

    - #### public GroovyPrintWriter(Writer out, boolean autoflush)

      Creates a writer that delegates to the supplied writer.

      Parameters:
        `out` - the underlying writer
        `autoflush` - whether println operations flush automatically

    - #### public GroovyPrintWriter(OutputStream out)

      Creates a writer for the supplied output stream.

      Parameters:
        `out` - the underlying output stream

    - #### public GroovyPrintWriter(OutputStream out, boolean autoflush)

      Creates a writer for the supplied output stream.

      Parameters:
        `out` - the underlying output stream
        `autoflush` - whether println operations flush automatically

    - #### public GroovyPrintWriter(String filename)

      Creates a writer for the supplied file name.

      throws:
        FileNotFoundException if the file cannot be opened
      Parameters:
        `filename` - the target file name

    - #### public GroovyPrintWriter(String filename, String csn)

      Creates a writer for the supplied file name using the given charset name.

      throws:
        FileNotFoundException if the file cannot be opened
      throws:
        UnsupportedEncodingException if the charset is unsupported
      Parameters:
        `filename` - the target file name
        `csn` - the charset name

  - ### Method Detail

    - #### public void print(Object x)

      Prints an object using Groovy formatting.

      Parameters:
        `x` - the value to print

    - #### public void println(Object x)

      Prints an object followed by a line separator using Groovy formatting.

      Parameters:
        `x` - the value to print