Package org.apache.groovy.nio.runtime

# Class WritablePath

java.lang.Object
org.apache.groovy.nio.runtime.WritablePath

All Implemented Interfaces:
  `Writable`, `Comparable<Path>`, `Iterable<Path>`, `Path`, `Watchable`

public class WritablePath extends Object implements Path, Writable
`Path` wrapper that also implements `Writable`.

All `Path` operations are delegated to the wrapped path, while `writeTo(Writer)` streams the path contents using the configured character encoding when one is supplied.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `WritablePath(Path delegate)`
  Creates a writable wrapper that uses the platform default charset when reading the path contents.
  `WritablePath(Path delegate, String encoding)`
  Creates a writable wrapper for the supplied path.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `int`
  `compareTo(Path other)`
  `boolean`
  `endsWith(String other)`
  `boolean`
  `endsWith(Path other)`
  `boolean`
  `equals(Object other)`
  `Path`
  `getFileName()`
  `FileSystem`
  `getFileSystem()`
  `Path`
  `getName(int index)`
  `int`
  `getNameCount()`
  `Path`
  `getParent()`
  `Path`
  `getRoot()`
  `int`
  `hashCode()`
  `boolean`
  `isAbsolute()`
  `Iterator<Path>`
  `iterator()`
  `Path`
  `normalize()`
  `WatchKey`
  `register(WatchService watcher, WatchEvent.Kind<?>... events)`
  `WatchKey`
  `register(WatchService watcher, WatchEvent.Kind<?>[] events, WatchEvent.Modifier... modifiers)`
  `Path`
  `relativize(Path other)`
  `Path`
  `resolve(String other)`
  `Path`
  `resolve(Path other)`
  `Path`
  `resolveSibling(String other)`
  `Path`
  `resolveSibling(Path other)`
  `boolean`
  `startsWith(String other)`
  `boolean`
  `startsWith(Path other)`
  `Path`
  `subpath(int beginIndex, int endIndex)`
  `Path`
  `toAbsolutePath()`
  `File`
  `toFile()`
  `Path`
  `toRealPath(LinkOption... options)`
  `String`
  `toString()`
  `URI`
  `toUri()`
  `Writer`
  `writeTo(Writer out)`
  Writes the wrapped path contents to the supplied writer.

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

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

  ### Methods inherited from interface java.lang.Iterable

  `forEach, spliterator`

- ## Constructor Details

  - ### WritablePath

    public WritablePath(Path delegate)
    Creates a writable wrapper that uses the platform default charset when reading the path contents.
    Parameters:
      `delegate` - the path to wrap

  - ### WritablePath

    public WritablePath(Path delegate, String encoding)
    Creates a writable wrapper for the supplied path.
    Parameters:
      `delegate` - the path to wrap
      `encoding` - the charset name to use when reading path contents; `null` uses the platform default charset

- ## Method Details

  - ### writeTo

    public Writer writeTo(Writer out) throws IOException
    Writes the wrapped path contents to the supplied writer.
    Specified by:
      `writeTo` in interface `Writable`
    Parameters:
      `out` - the destination writer
    Returns:
      the supplied writer
    Throws:
      `IOException` - if the path cannot be read or the writer cannot be updated

  - ### getFileSystem

    public FileSystem getFileSystem()
    Specified by:
      `getFileSystem` in interface `Path`

  - ### isAbsolute

    public boolean isAbsolute()
    Specified by:
      `isAbsolute` in interface `Path`

  - ### getRoot

    public Path getRoot()
    Specified by:
      `getRoot` in interface `Path`

  - ### getFileName

    public Path getFileName()
    Specified by:
      `getFileName` in interface `Path`

  - ### getParent

    public Path getParent()
    Specified by:
      `getParent` in interface `Path`

  - ### getNameCount

    public int getNameCount()
    Specified by:
      `getNameCount` in interface `Path`

  - ### getName

    public Path getName(int index)
    Specified by:
      `getName` in interface `Path`

  - ### subpath

    public Path subpath(int beginIndex, int endIndex)
    Specified by:
      `subpath` in interface `Path`

  - ### startsWith

    public boolean startsWith(Path other)
    Specified by:
      `startsWith` in interface `Path`

  - ### startsWith

    public boolean startsWith(String other)
    Specified by:
      `startsWith` in interface `Path`

  - ### endsWith

    public boolean endsWith(Path other)
    Specified by:
      `endsWith` in interface `Path`

  - ### endsWith

    public boolean endsWith(String other)
    Specified by:
      `endsWith` in interface `Path`

  - ### normalize

    public Path normalize()
    Specified by:
      `normalize` in interface `Path`

  - ### resolve

    public Path resolve(Path other)
    Specified by:
      `resolve` in interface `Path`

  - ### resolve

    public Path resolve(String other)
    Specified by:
      `resolve` in interface `Path`

  - ### resolveSibling

    public Path resolveSibling(Path other)
    Specified by:
      `resolveSibling` in interface `Path`

  - ### resolveSibling

    public Path resolveSibling(String other)
    Specified by:
      `resolveSibling` in interface `Path`

  - ### relativize

    public Path relativize(Path other)
    Specified by:
      `relativize` in interface `Path`

  - ### toUri

    public URI toUri()
    Specified by:
      `toUri` in interface `Path`

  - ### toAbsolutePath

    public Path toAbsolutePath()
    Specified by:
      `toAbsolutePath` in interface `Path`

  - ### toRealPath

    public Path toRealPath(LinkOption... options) throws IOException
    Specified by:
      `toRealPath` in interface `Path`
    Throws:
      `IOException`

  - ### toFile

    public File toFile()
    Specified by:
      `toFile` in interface `Path`

  - ### register

    public WatchKey register(WatchService watcher, WatchEvent.Kind<?>[] events, WatchEvent.Modifier... modifiers) throws IOException
    Specified by:
      `register` in interface `Path`
    Specified by:
      `register` in interface `Watchable`
    Throws:
      `IOException`

  - ### register

    public WatchKey register(WatchService watcher, WatchEvent.Kind<?>... events) throws IOException
    Specified by:
      `register` in interface `Path`
    Specified by:
      `register` in interface `Watchable`
    Throws:
      `IOException`

  - ### iterator

    public Iterator<Path> iterator()
    Specified by:
      `iterator` in interface `Iterable<Path>`
    Specified by:
      `iterator` in interface `Path`

  - ### compareTo

    public int compareTo(Path other)
    Specified by:
      `compareTo` in interface `Comparable<Path>`
    Specified by:
      `compareTo` in interface `Path`

  - ### equals

    public boolean equals(Object other)
    Specified by:
      `equals` in interface `Path`
    Overrides:
      `equals` in class `Object`

  - ### hashCode

    public int hashCode()
    Specified by:
      `hashCode` in interface `Path`
    Overrides:
      `hashCode` in class `Object`

  - ### toString

    public String toString()
    Specified by:
      `toString` in interface `Path`
    Overrides:
      `toString` in class `Object`