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>`

public class WritableFile extends File implements Writable
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:
  - Serialized Form

- ## Field Summary

  ### Fields inherited from class java.io.File

  `pathSeparator, pathSeparatorChar, separator, separatorChar`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `WritableFile(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

  Modifier and Type
  Method
  Description
  `Writer`
  `writeTo(Writer out)`
  Writes this file's contents to the specified Writer.

  ### 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`

  ### Methods inherited from class java.lang.Object

  `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- ## Constructor Details

  - ### WritableFile

    public WritableFile(File delegate)
    Constructs a WritableFile from a delegate File with default character encoding.
    Parameters:
      `delegate` - the underlying `File` to wrap

  - ### WritableFile

    public WritableFile(File delegate, String encoding)
    Constructs a WritableFile from a delegate File with optional character encoding.
    Parameters:
      `delegate` - the underlying `File` to wrap
      `encoding` - the character encoding to use when reading the file, or `null` for default

- ## Method Details

  - ### writeTo

    public Writer writeTo(Writer out) throws IOException
    Writes this file's contents to the specified Writer. If encoding was specified, uses that encoding when reading the file.
    Specified by:
      `writeTo` in interface `Writable`
    Parameters:
      `out` - the `Writer` to write the file contents to
    Returns:
      the same `Writer` for method chaining
    Throws:
      `IOException` - if an I/O error occurs during reading or writing