Package groovy.io
Class GroovyPrintWriter
java.lang.Object
java.io.Writer
java.io.PrintWriter
groovy.io.GroovyPrintWriter
- All Implemented Interfaces:
Closeable,Flushable,Appendable,AutoCloseable
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
-
Field Summary
Fields inherited from class java.io.PrintWriter
out -
Constructor Summary
ConstructorsConstructorDescriptionGroovyPrintWriter(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.Creates a writer for the supplied output stream.GroovyPrintWriter(OutputStream out, boolean autoflush) Creates a writer for the supplied output stream.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(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. -
Method Summary
Methods inherited from class java.io.PrintWriter
append, append, append, checkError, clearError, close, flush, format, format, print, print, print, print, print, print, print, print, printf, printf, println, println, println, println, println, println, println, println, println, setError, write, write, write, write, writeMethods inherited from class java.io.Writer
nullWriter
-
Constructor Details
-
GroovyPrintWriter
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 filecsn- the charset name- Throws:
FileNotFoundException- if the file cannot be openedUnsupportedEncodingException- if the charset is unsupported
-
GroovyPrintWriter
Creates a writer that delegates to the supplied writer.- Parameters:
out- the underlying writer
-
GroovyPrintWriter
Creates a writer that delegates to the supplied writer.- Parameters:
out- the underlying writerautoflush- whether println operations flush automatically
-
GroovyPrintWriter
Creates a writer for the supplied output stream.- Parameters:
out- the underlying output stream
-
GroovyPrintWriter
Creates a writer for the supplied output stream.- Parameters:
out- the underlying output streamautoflush- whether println operations flush automatically
-
GroovyPrintWriter
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 namecsn- the charset name- Throws:
FileNotFoundException- if the file cannot be openedUnsupportedEncodingException- if the charset is unsupported
-
-
Method Details
-
print
Prints an object using Groovy formatting.- Overrides:
printin classPrintWriter- Parameters:
x- the value to print
-
println
Prints an object followed by a line separator using Groovy formatting.- Overrides:
printlnin classPrintWriter- Parameters:
x- the value to print
-