Package groovy.io

Class GroovyPrintWriter

All Implemented Interfaces:
Closeable, Flushable, Appendable, AutoCloseable

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 Details

    • GroovyPrintWriter

      public GroovyPrintWriter(File file) throws FileNotFoundException
      Creates a writer for the supplied file.
      Parameters:
      file - the target file
      Throws:
      FileNotFoundException - if the file cannot be opened
    • GroovyPrintWriter

      public GroovyPrintWriter(File file, String csn) throws FileNotFoundException, UnsupportedEncodingException
      Creates a writer for the supplied file using the given charset name.
      Parameters:
      file - the target file
      csn - the charset name
      Throws:
      FileNotFoundException - if the file cannot be opened
      UnsupportedEncodingException - if the charset is unsupported
    • GroovyPrintWriter

      public GroovyPrintWriter(Writer out)
      Creates a writer that delegates to the supplied writer.
      Parameters:
      out - the underlying writer
    • GroovyPrintWriter

      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
    • GroovyPrintWriter

      public GroovyPrintWriter(OutputStream out)
      Creates a writer for the supplied output stream.
      Parameters:
      out - the underlying output stream
    • GroovyPrintWriter

      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
    • GroovyPrintWriter

      public GroovyPrintWriter(String filename) throws FileNotFoundException
      Creates a writer for the supplied file name.
      Parameters:
      filename - the target file name
      Throws:
      FileNotFoundException - if the file cannot be opened
    • GroovyPrintWriter

      public GroovyPrintWriter(String filename, String csn) throws FileNotFoundException, UnsupportedEncodingException
      Creates a writer for the supplied file name using the given charset name.
      Parameters:
      filename - the target file name
      csn - the charset name
      Throws:
      FileNotFoundException - if the file cannot be opened
      UnsupportedEncodingException - if the charset is unsupported
  • Method Details

    • print

      public void print(Object x)
      Prints an object using Groovy formatting.
      Overrides:
      print in class PrintWriter
      Parameters:
      x - the value to print
    • println

      public void println(Object x)
      Prints an object followed by a line separator using Groovy formatting.
      Overrides:
      println in class PrintWriter
      Parameters:
      x - the value to print