Package org.codehaus.groovy.runtime
Class WritableFile
java.lang.Object
java.io.File
org.codehaus.groovy.runtime.WritableFile
- All Implemented Interfaces:
Writable,Serializable,Comparable<File>
A file wrapper implementing the
Writable interface to support writing file contents.
Allows a file to be written to any output stream, optionally with a specified character encoding.- See Also:
-
Field Summary
Fields inherited from class java.io.File
pathSeparator, pathSeparatorChar, separator, separatorChar -
Constructor Summary
ConstructorsConstructorDescriptionWritableFile(File delegate) Constructs a WritableFile from a delegate File with default character encoding.WritableFile(File delegate, String encoding) Constructs a WritableFile from a delegate File with optional character encoding. -
Method Summary
Methods inherited from class java.io.File
canExecute, canRead, canWrite, compareTo, createNewFile, createTempFile, createTempFile, delete, deleteOnExit, equals, exists, getAbsoluteFile, getAbsolutePath, getCanonicalFile, getCanonicalPath, getFreeSpace, getName, getParent, getParentFile, getPath, getTotalSpace, getUsableSpace, hashCode, isAbsolute, isDirectory, isFile, isHidden, lastModified, length, list, list, listFiles, listFiles, listFiles, listRoots, mkdir, mkdirs, renameTo, setExecutable, setExecutable, setLastModified, setReadable, setReadable, setReadOnly, setWritable, setWritable, toPath, toString, toURI, toURL
-
Constructor Details
-
WritableFile
Constructs a WritableFile from a delegate File with default character encoding.- Parameters:
delegate- the underlyingFileto wrap
-
WritableFile
Constructs a WritableFile from a delegate File with optional character encoding.- Parameters:
delegate- the underlyingFileto wrapencoding- the character encoding to use when reading the file, ornullfor default
-
-
Method Details
-
writeTo
Writes this file's contents to the specified Writer. If encoding was specified, uses that encoding when reading the file.- Specified by:
writeToin interfaceWritable- Parameters:
out- theWriterto write the file contents to- Returns:
- the same
Writerfor method chaining - Throws:
IOException- if an I/O error occurs during reading or writing
-