Package org.apache.groovy.nio.runtime
Class WritablePath
java.lang.Object
org.apache.groovy.nio.runtime.WritablePath
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
ConstructorsConstructorDescriptionWritablePath(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 TypeMethodDescriptionintbooleanbooleanbooleangetName(int index) intgetRoot()inthashCode()booleaniterator()register(WatchService watcher, WatchEvent.Kind<?>... events) register(WatchService watcher, WatchEvent.Kind<?>[] events, WatchEvent.Modifier... modifiers) relativize(Path other) resolveSibling(String other) resolveSibling(Path other) booleanstartsWith(String other) booleanstartsWith(Path other) subpath(int beginIndex, int endIndex) toFile()toRealPath(LinkOption... options) toString()toUri()Writes the wrapped path contents to the supplied writer.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
WritablePath
Creates a writable wrapper that uses the platform default charset when reading the path contents.- Parameters:
delegate- the path to wrap
-
WritablePath
Creates a writable wrapper for the supplied path.- Parameters:
delegate- the path to wrapencoding- the charset name to use when reading path contents;nulluses the platform default charset
-
-
Method Details
-
writeTo
Writes the wrapped path contents to the supplied writer.- Specified by:
writeToin interfaceWritable- Parameters:
out- the destination writer- Returns:
- the supplied writer
- Throws:
IOException- if the path cannot be read or the writer cannot be updated
-
getFileSystem
- Specified by:
getFileSystemin interfacePath
-
isAbsolute
public boolean isAbsolute()- Specified by:
isAbsolutein interfacePath
-
getRoot
-
getFileName
- Specified by:
getFileNamein interfacePath
-
getParent
-
getNameCount
public int getNameCount()- Specified by:
getNameCountin interfacePath
-
getName
-
subpath
-
startsWith
- Specified by:
startsWithin interfacePath
-
startsWith
- Specified by:
startsWithin interfacePath
-
endsWith
-
endsWith
-
normalize
-
resolve
-
resolve
-
resolveSibling
- Specified by:
resolveSiblingin interfacePath
-
resolveSibling
- Specified by:
resolveSiblingin interfacePath
-
relativize
- Specified by:
relativizein interfacePath
-
toUri
-
toAbsolutePath
- Specified by:
toAbsolutePathin interfacePath
-
toRealPath
- Specified by:
toRealPathin interfacePath- Throws:
IOException
-
toFile
-
register
public WatchKey register(WatchService watcher, WatchEvent.Kind<?>[] events, WatchEvent.Modifier... modifiers) throws IOException - Specified by:
registerin interfacePath- Specified by:
registerin interfaceWatchable- Throws:
IOException
-
register
- Specified by:
registerin interfacePath- Specified by:
registerin interfaceWatchable- Throws:
IOException
-
iterator
-
compareTo
- Specified by:
compareToin interfaceComparable<Path>- Specified by:
compareToin interfacePath
-
equals
-
hashCode
public int hashCode() -
toString
-