@Deprecated public class NioGroovyMethods extends DefaultGroovyMethodsSupport
public static T eachLine(InputStream self, Closure c)
provides a eachLine(Closure c)
method for InputStream
.
NOTE: While this class contains many 'public' static methods, it is
primarily regarded as an internal class (its internal package name
suggests this also). We value backwards compatibility of these
methods when used within Groovy but value less backwards compatibility
at the Java method call level. I.e. future versions of Groovy may
remove or move a method call in this file but would normally
aim to keep the method available from within Groovy.Constructor and Description |
---|
NioGroovyMethods()
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
static void |
append(Path self,
byte[] bytes)
Deprecated.
|
static void |
append(Path self,
InputStream stream)
Deprecated.
|
static void |
append(Path self,
Object text)
Deprecated.
|
static void |
append(Path self,
Object text,
boolean writeBom)
Deprecated.
|
static void |
append(Path self,
Object text,
String charset)
Deprecated.
|
static void |
append(Path self,
Object text,
String charset,
boolean writeBom)
Deprecated.
|
static void |
append(Path file,
Reader reader)
Deprecated.
|
static void |
append(Path file,
Reader reader,
boolean writeBom)
Deprecated.
|
static void |
append(Path file,
Reader reader,
String charset)
Deprecated.
|
static void |
append(Path file,
Reader reader,
String charset,
boolean writeBom)
Deprecated.
|
static void |
append(Path file,
Writer writer)
Deprecated.
|
static void |
append(Path file,
Writer writer,
boolean writeBom)
Deprecated.
|
static void |
append(Path file,
Writer writer,
String charset)
Deprecated.
|
static void |
append(Path file,
Writer writer,
String charset,
boolean writeBom)
Deprecated.
|
static <T> T |
asType(Path path,
Class<T> c)
Deprecated.
|
static Path |
asWritable(Path self)
Deprecated.
|
static Path |
asWritable(Path self,
String encoding)
Deprecated.
|
static boolean |
deleteDir(Path self)
Deprecated.
|
static void |
eachByte(Path self,
Closure closure)
Deprecated.
|
static void |
eachByte(Path self,
int bufferLen,
Closure closure)
Deprecated.
|
static void |
eachDir(Path self,
Closure closure)
Deprecated.
|
static void |
eachDirMatch(Path self,
Object nameFilter,
Closure closure)
Deprecated.
|
static void |
eachDirRecurse(Path self,
Closure closure)
Deprecated.
|
static void |
eachFile(Path self,
Closure closure)
Deprecated.
|
static void |
eachFile(Path self,
FileType fileType,
Closure closure)
Deprecated.
|
static void |
eachFileMatch(Path self,
FileType fileType,
Object nameFilter,
Closure closure)
Deprecated.
|
static void |
eachFileMatch(Path self,
Object nameFilter,
Closure closure)
Deprecated.
|
static void |
eachFileRecurse(Path self,
Closure closure)
Deprecated.
|
static void |
eachFileRecurse(Path self,
FileType fileType,
Closure closure)
Deprecated.
|
static <T> T |
eachLine(Path self,
Closure<T> closure)
Deprecated.
|
static <T> T |
eachLine(Path self,
int firstLine,
Closure<T> closure)
Deprecated.
|
static <T> T |
eachLine(Path self,
String charset,
Closure<T> closure)
Deprecated.
|
static <T> T |
eachLine(Path self,
String charset,
int firstLine,
Closure<T> closure)
Deprecated.
|
static void |
eachObject(Path self,
Closure closure)
Deprecated.
|
static Writable |
filterLine(Path self,
Closure closure)
Deprecated.
|
static Writable |
filterLine(Path self,
String charset,
Closure closure)
Deprecated.
|
static void |
filterLine(Path self,
Writer writer,
Closure closure)
Deprecated.
|
static void |
filterLine(Path self,
Writer writer,
String charset,
Closure closure)
Deprecated.
|
static byte[] |
getBytes(Path self)
Deprecated.
|
static String |
getText(Path self)
Deprecated.
|
static String |
getText(Path self,
String charset)
Deprecated.
|
static Path |
leftShift(Path self,
byte[] bytes)
Deprecated.
|
static Path |
leftShift(Path path,
InputStream data)
Deprecated.
|
static Path |
leftShift(Path self,
Object text)
Deprecated.
|
static DataInputStream |
newDataInputStream(Path self)
Deprecated.
|
static DataOutputStream |
newDataOutputStream(Path self)
Deprecated.
|
static BufferedInputStream |
newInputStream(Path self)
Deprecated.
|
static ObjectInputStream |
newObjectInputStream(Path self)
Deprecated.
|
static ObjectInputStream |
newObjectInputStream(Path self,
ClassLoader classLoader)
Deprecated.
|
static ObjectOutputStream |
newObjectOutputStream(Path self)
Deprecated.
|
static BufferedOutputStream |
newOutputStream(Path self)
Deprecated.
|
static PrintWriter |
newPrintWriter(Path self)
Deprecated.
|
static PrintWriter |
newPrintWriter(Path self,
String charset)
Deprecated.
|
static BufferedReader |
newReader(Path self)
Deprecated.
|
static BufferedReader |
newReader(Path self,
String charset)
Deprecated.
|
static BufferedWriter |
newWriter(Path self)
Deprecated.
|
static BufferedWriter |
newWriter(Path self,
boolean append)
Deprecated.
|
static BufferedWriter |
newWriter(Path self,
String charset)
Deprecated.
|
static BufferedWriter |
newWriter(Path self,
String charset,
boolean append)
Deprecated.
|
static BufferedWriter |
newWriter(Path self,
String charset,
boolean append,
boolean writeBom)
Deprecated.
|
static byte[] |
readBytes(Path self)
Deprecated.
|
static List<String> |
readLines(Path self)
Deprecated.
|
static List<String> |
readLines(Path self,
String charset)
Deprecated.
|
static boolean |
renameTo(Path self,
String newPathName)
Deprecated.
|
static boolean |
renameTo(Path self,
URI newPathName)
Deprecated.
|
static void |
setBytes(Path self,
byte[] bytes)
Deprecated.
|
static void |
setText(Path self,
String text)
Deprecated.
|
static void |
setText(Path self,
String text,
String charset)
Deprecated.
|
static long |
size(Path self)
Deprecated.
|
static <T> T |
splitEachLine(Path self,
Pattern pattern,
Closure<T> closure)
Deprecated.
|
static <T> T |
splitEachLine(Path self,
Pattern pattern,
String charset,
Closure<T> closure)
Deprecated.
|
static <T> T |
splitEachLine(Path self,
String regex,
Closure<T> closure)
Deprecated.
|
static <T> T |
splitEachLine(Path self,
String regex,
String charset,
Closure<T> closure)
Deprecated.
|
static void |
traverse(Path self,
Closure closure)
Deprecated.
|
static void |
traverse(Path self,
Map<String,Object> options)
Deprecated.
|
static void |
traverse(Path self,
Map<String,Object> options,
Closure closure)
Deprecated.
|
static <T> T |
withCloseable(Closeable self,
Closure<T> action)
Deprecated.
|
static <T> T |
withDataInputStream(Path self,
Closure<T> closure)
Deprecated.
|
static <T> T |
withDataOutputStream(Path self,
Closure<T> closure)
Deprecated.
|
static Object |
withInputStream(Path self,
Closure closure)
Deprecated.
|
static <T> T |
withObjectInputStream(Path self,
ClassLoader classLoader,
Closure<T> closure)
Deprecated.
|
static <T> T |
withObjectInputStream(Path path,
Closure<T> closure)
Deprecated.
|
static <T> T |
withObjectOutputStream(Path self,
Closure<T> closure)
Deprecated.
|
static Object |
withOutputStream(Path self,
Closure closure)
Deprecated.
|
static <T> T |
withPrintWriter(Path self,
Closure<T> closure)
Deprecated.
|
static <T> T |
withPrintWriter(Path self,
String charset,
Closure<T> closure)
Deprecated.
|
static <T> T |
withReader(Path self,
Closure<T> closure)
Deprecated.
|
static <T> T |
withReader(Path self,
String charset,
Closure<T> closure)
Deprecated.
|
static <T> T |
withWriter(Path self,
Closure<T> closure)
Deprecated.
|
static <T> T |
withWriter(Path self,
String charset,
boolean writeBom,
Closure<T> closure)
Deprecated.
|
static <T> T |
withWriter(Path self,
String charset,
Closure<T> closure)
Deprecated.
|
static <T> T |
withWriterAppend(Path self,
Closure<T> closure)
Deprecated.
|
static <T> T |
withWriterAppend(Path self,
String charset,
boolean writeBom,
Closure<T> closure)
Deprecated.
|
static <T> T |
withWriterAppend(Path self,
String charset,
Closure<T> closure)
Deprecated.
|
static void |
write(Path self,
String text)
Deprecated.
|
static void |
write(Path self,
String text,
boolean writeBom)
Deprecated.
|
static void |
write(Path self,
String text,
String charset)
Deprecated.
|
static void |
write(Path self,
String text,
String charset,
boolean writeBom)
Deprecated.
|
cloneSimilarCollection, cloneSimilarMap, closeQuietly, closeWithWarning, createSimilarArray, createSimilarCollection, createSimilarCollection, createSimilarCollection, createSimilarList, createSimilarMap, createSimilarOrDefaultCollection, createSimilarQueue, createSimilarSet, normaliseIndex, sameType, subListBorders, subListBorders, writeUTF16BomIfRequired, writeUTF16BomIfRequired, writeUTF16BomIfRequired, writeUTF16BomIfRequired
@Deprecated public static long size(Path self) throws IOException
size()
method for Path
.self
- a Path
objectIOException
@Deprecated public static ObjectOutputStream newObjectOutputStream(Path self) throws IOException
self
- a Path
objectIOException
- if an IOException occurs.@Deprecated public static <T> T withObjectOutputStream(Path self, Closure<T> closure) throws IOException
self
- a Pathclosure
- a closureIOException
- if an IOException occurs.IOGroovyMethods.withStream(java.io.OutputStream, groovy.lang.Closure)
@Deprecated public static ObjectInputStream newObjectInputStream(Path self) throws IOException
self
- a Path
objectIOException
- if an IOException occurs.@Deprecated public static ObjectInputStream newObjectInputStream(Path self, ClassLoader classLoader) throws IOException
self
- a Path
objectclassLoader
- the class loader to use when loading the classIOException
- if an IOException occurs.@Deprecated public static void eachObject(Path self, Closure closure) throws IOException, ClassNotFoundException
self
- a Path
objectclosure
- a closureIOException
- if an IOException occurs.ClassNotFoundException
- if the class is not found.IOGroovyMethods.eachObject(java.io.ObjectInputStream, groovy.lang.Closure)
@Deprecated public static <T> T withObjectInputStream(Path path, Closure<T> closure) throws IOException
path
- a Pathclosure
- a closureIOException
- if an IOException occurs.IOGroovyMethods.withStream(java.io.InputStream, groovy.lang.Closure)
@Deprecated public static <T> T withObjectInputStream(Path self, ClassLoader classLoader, Closure<T> closure) throws IOException
self
- a PathclassLoader
- the class loader to use when loading the classclosure
- a closureIOException
- if an IOException occurs.IOGroovyMethods.withStream(java.io.InputStream, groovy.lang.Closure)
@Deprecated public static <T> T eachLine(Path self, Closure<T> closure) throws IOException
self
- a Pathclosure
- a closure (arg 1 is line, optional arg 2 is line number starting at line 1)IOException
- if an IOException occurs.eachLine(Path, int, groovy.lang.Closure)
@Deprecated public static <T> T eachLine(Path self, String charset, Closure<T> closure) throws IOException
self
- a Pathcharset
- opens the file with a specified charsetclosure
- a closure (arg 1 is line, optional arg 2 is line number starting at line 1)IOException
- if an IOException occurs.eachLine(Path, String, int, groovy.lang.Closure)
@Deprecated public static <T> T eachLine(Path self, int firstLine, Closure<T> closure) throws IOException
self
- a PathfirstLine
- the line number value used for the first line (default is 1, set to 0 to start counting from 0)closure
- a closure (arg 1 is line, optional arg 2 is line number)IOException
- if an IOException occurs.IOGroovyMethods.eachLine(java.io.Reader, int, groovy.lang.Closure)
@Deprecated public static <T> T eachLine(Path self, String charset, int firstLine, Closure<T> closure) throws IOException
self
- a Pathcharset
- opens the file with a specified charsetfirstLine
- the line number value used for the first line (default is 1, set to 0 to start counting from 0)closure
- a closure (arg 1 is line, optional arg 2 is line number)IOException
- if an IOException occurs.IOGroovyMethods.eachLine(java.io.Reader, int, groovy.lang.Closure)
@Deprecated public static <T> T splitEachLine(Path self, String regex, Closure<T> closure) throws IOException
self
- a Pathregex
- the delimiting regular expressionclosure
- a closureIOException
- if an IOException occurs.PatternSyntaxException
- if the regular expression's syntax is invalidIOGroovyMethods.splitEachLine(java.io.Reader, String, groovy.lang.Closure)
@Deprecated public static <T> T splitEachLine(Path self, Pattern pattern, Closure<T> closure) throws IOException
self
- a Pathpattern
- the regular expression Pattern for the delimiterclosure
- a closureIOException
- if an IOException occurs.IOGroovyMethods.splitEachLine(java.io.Reader, java.util.regex.Pattern, groovy.lang.Closure)
@Deprecated public static <T> T splitEachLine(Path self, String regex, String charset, Closure<T> closure) throws IOException
self
- a Pathregex
- the delimiting regular expressioncharset
- opens the file with a specified charsetclosure
- a closureIOException
- if an IOException occurs.PatternSyntaxException
- if the regular expression's syntax is invalidIOGroovyMethods.splitEachLine(java.io.Reader, String, groovy.lang.Closure)
@Deprecated public static <T> T splitEachLine(Path self, Pattern pattern, String charset, Closure<T> closure) throws IOException
self
- a Pathpattern
- the regular expression Pattern for the delimitercharset
- opens the file with a specified charsetclosure
- a closureIOException
- if an IOException occurs.IOGroovyMethods.splitEachLine(java.io.Reader, java.util.regex.Pattern, groovy.lang.Closure)
@Deprecated public static List<String> readLines(Path self) throws IOException
self
- a PathIOException
- if an IOException occurs.IOGroovyMethods.readLines(java.io.Reader)
@Deprecated public static List<String> readLines(Path self, String charset) throws IOException
self
- a Pathcharset
- opens the file with a specified charsetIOException
- if an IOException occurs.IOGroovyMethods.readLines(java.io.Reader)
@Deprecated public static String getText(Path self, String charset) throws IOException
self
- the file whose content we want to readcharset
- the charset used to read the content of the fileIOException
- if an IOException occurs.@Deprecated public static String getText(Path self) throws IOException
self
- the file whose content we want to readIOException
- if an IOException occurs.@Deprecated public static byte[] getBytes(Path self) throws IOException
self
- the file whose content we want to readIOException
- if an IOException occurs.@Deprecated public static void setBytes(Path self, byte[] bytes) throws IOException
self
- the file to write tobytes
- the byte[] to write to the fileIOException
- if an IOException occurs.@Deprecated public static void write(Path self, String text) throws IOException
self
- a Pathtext
- the text to write to the PathIOException
- if an IOException occurs.@Deprecated public static void write(Path self, String text, boolean writeBom) throws IOException
writeBom
is true
, the requisite byte order
mark is written to the file before the text.self
- a Pathtext
- the text to write to the PathwriteBom
- whether to write the BOMIOException
- if an IOException occurs.@Deprecated public static void setText(Path self, String text) throws IOException
self
- a Pathtext
- the text to write to the PathIOException
- if an IOException occurs.write(Path, String)
@Deprecated public static void setText(Path self, String text, String charset) throws IOException
myFile.setText('some text', charset)or with some help from
ExpandoMetaClass
, you could do something like:
myFile.metaClass.setText = { String s ->
delegate.setText(s, 'UTF-8') }
myfile.text = 'some text'
self
- A Pathcharset
- The charset used when writing to the filetext
- The text to write to the PathIOException
- if an IOException occurs.write(Path, String, String)
@Deprecated public static Path leftShift(Path self, Object text) throws IOException
self
- a Pathtext
- the text to write to the PathIOException
- if an IOException occurs.@Deprecated public static Path leftShift(Path self, byte[] bytes) throws IOException
self
- a Pathbytes
- the byte array to append to the end of the PathIOException
- if an IOException occurs.@Deprecated public static Path leftShift(Path path, InputStream data) throws IOException
append(Path, java.io.InputStream)
path
- a Pathdata
- an InputStream of data to write to the fileIOException
- if an IOException occurs.@Deprecated public static void write(Path self, String text, String charset) throws IOException
self
- a Pathtext
- the text to write to the Pathcharset
- the charset usedIOException
- if an IOException occurs.@Deprecated public static void write(Path self, String text, String charset, boolean writeBom) throws IOException
writeBom
is true
, the requisite byte order
mark is written to the file before the text.self
- a Pathtext
- the text to write to the Pathcharset
- the charset usedwriteBom
- whether to write a BOMIOException
- if an IOException occurs.@Deprecated public static void append(Path self, Object text) throws IOException
self
- a Pathtext
- the text to append at the end of the PathIOException
- if an IOException occurs.@Deprecated public static void append(Path file, Reader reader) throws IOException
file
- a Pathreader
- the Reader supplying the text to append at the end of the FileIOException
- if an IOException occurs.@Deprecated public static void append(Path file, Writer writer) throws IOException
file
- a Filewriter
- the Writer supplying the text to append at the end of the FileIOException
- if an IOException occurs.@Deprecated public static void append(Path self, byte[] bytes) throws IOException
self
- a Pathbytes
- the byte array to append to the end of the PathIOException
- if an IOException occurs.@Deprecated public static void append(Path self, InputStream stream) throws IOException
self
- a Pathstream
- stream to read data from.IOException
- if an IOException occurs.@Deprecated public static void append(Path self, Object text, boolean writeBom) throws IOException
writeBom
is true
, the requisite byte order
mark is written to the file before the text.self
- a Pathtext
- the text to append at the end of the PathwriteBom
- whether to write the BOMIOException
- if an IOException occurs.@Deprecated public static void append(Path self, Object text, String charset) throws IOException
self
- a Pathtext
- the text to append at the end of the Pathcharset
- the charset usedIOException
- if an IOException occurs.@Deprecated public static void append(Path self, Object text, String charset, boolean writeBom) throws IOException
writeBom
is true
, and the file doesn't already
exist, the requisite byte order mark is written to the file before the
text is appended.self
- a Pathtext
- the text to append at the end of the Pathcharset
- the charset usedwriteBom
- whether to write the BOMIOException
- if an IOException occurs.@Deprecated public static void append(Path file, Writer writer, boolean writeBom) throws IOException
writeBom
is true
, and the file doesn't already
exist, the requisite byte order mark is written to the file before the
text is appended.file
- a Filewriter
- the Writer supplying the text to append at the end of the FilewriteBom
- whether to write the BOMIOException
- if an IOException occurs.@Deprecated public static void append(Path file, Writer writer, String charset) throws IOException
file
- a Filewriter
- the Writer supplying the text to append at the end of the Filecharset
- the charset usedIOException
- if an IOException occurs.@Deprecated public static void append(Path file, Writer writer, String charset, boolean writeBom) throws IOException
writeBom
is true
, and the file doesn't already
exist, the requisite byte order mark is written to the file before the
text is appended.file
- a Filewriter
- the Writer supplying the text to append at the end of the Filecharset
- the charset usedwriteBom
- whether to write the BOMIOException
- if an IOException occurs.@Deprecated public static void append(Path file, Reader reader, boolean writeBom) throws IOException
writeBom
is true
, and the file doesn't already
exist, the requisite byte order mark is written to the file before the
text is appended.file
- a Filereader
- the Reader supplying the text to append at the end of the FilewriteBom
- whether to write the BOMIOException
- if an IOException occurs.@Deprecated public static void append(Path file, Reader reader, String charset) throws IOException
file
- a Filereader
- the Reader supplying the text to append at the end of the Filecharset
- the charset usedIOException
- if an IOException occurs.@Deprecated public static void append(Path file, Reader reader, String charset, boolean writeBom) throws IOException
writeBom
is true
, and the file doesn't already
exist, the requisite byte order mark is written to the file before the
text is appended.file
- a Filereader
- the Reader supplying the text to append at the end of the Filecharset
- the charset usedwriteBom
- whether to write the BOMIOException
- if an IOException occurs.@Deprecated public static void eachFile(Path self, FileType fileType, Closure closure) throws IOException
self
- a Path (that happens to be a folder/directory)fileType
- if normal files or directories or both should be processedclosure
- the closure to invokeFileNotFoundException
- if the given directory does not existIllegalArgumentException
- if the provided Path object does not represent a directoryIOException
@Deprecated public static void eachFile(Path self, Closure closure) throws IOException
self
- a Path (that happens to be a folder/directory)closure
- a closure (the parameter is the Path for the 'child' file)FileNotFoundException
- if the given directory does not existIllegalArgumentException
- if the provided Path object does not represent a directoryIOException
eachFile(Path, groovy.io.FileType, groovy.lang.Closure)
@Deprecated public static void eachDir(Path self, Closure closure) throws IOException
self
- a Path (that happens to be a folder/directory)closure
- a closure (the parameter is the Path for the subdirectory file)FileNotFoundException
- if the given directory does not existIllegalArgumentException
- if the provided Path object does not represent a directoryIOException
eachFile(Path, groovy.io.FileType, groovy.lang.Closure)
@Deprecated public static void eachFileRecurse(Path self, FileType fileType, Closure closure) throws IOException
closure
passing it the current
file (which may be a normal file or subdirectory) and then if a subdirectory was encountered,
recursively processing the subdirectory. Whether the closure is called is determined by whether
the file was a normal file or subdirectory and the value of fileType.self
- a Path (that happens to be a folder/directory)fileType
- if normal files or directories or both should be processedclosure
- the closure to invoke on each fileFileNotFoundException
- if the given directory does not existIllegalArgumentException
- if the provided Path object does not represent a directoryIOException
@Deprecated public static void traverse(Path self, Map<String,Object> options, Closure closure) throws IOException
closure
passing it the current
file (which may be a normal file or subdirectory) and then if a subdirectory was encountered,
recursively processing the subdirectory.
The traversal can be adapted by providing various options in the options
Map according
to the following keys:
FileType
enum to determine if normal files or directories or both are processedClosure
run before each directory is processed and optionally returning a FileVisitResult
value
which can be used to control subsequent processing.Closure
run after each directory is processed and optionally returning a FileVisitResult
value
which can be used to control subsequent processing.FileType.FILES
)DefaultGroovyMethods.isCase(Object, Object)
method). If set,
only files/dirs which match are candidates for visiting.DefaultGroovyMethods.isCase(Object, Object)
method). If set,
only files/dirs which match are candidates for visiting. (Must not be set if 'filter' is set)DefaultGroovyMethods.isCase(Object, Object)
method).
If set, any candidates which match won't be visited.DefaultGroovyMethods.isCase(Object, Object)
method).
If set, any candidates which match won't be visited. (Must not be set if 'excludeFilter' is set)Closure
which if set causes the files and subdirectories for each directory to be processed in sorted order.
Note that even when processing only files, the order of visited subdirectories will be affected by this parameter.def totalSize = 0 def count = 0 def sortByTypeThenName = { a, b->
a.isFile() != b.isFile() ? a.isFile()<=>
b.isFile() : a.name<=>
b.name } rootDir.traverse( type : FILES, nameFilter : ~/.*\.groovy/, preDir : { if (it.name == '.svn') return SKIP_SUBTREE }, postDir : { println "Found $count files in $it.name totalling $totalSize bytes" totalSize = 0; count = 0 }, postRoot : true sort : sortByTypeThenName ) {it->
totalSize += it.size(); count++ }
self
- a Path (that happens to be a folder/directory)options
- a Map of options to alter the traversal behaviorclosure
- the Closure to invoke on each file/directory and optionally returning a FileVisitResult
value
which can be used to control subsequent processingFileNotFoundException
- if the given directory does not existIllegalArgumentException
- if the provided Path object does not represent a directory or illegal filter combinations are suppliedIOException
DefaultGroovyMethods.sort(java.util.Collection, groovy.lang.Closure)
,
FileVisitResult
,
FileType
@Deprecated public static void traverse(Path self, Closure closure) throws IOException
traverse(Path, java.util.Map, groovy.lang.Closure)
when
no options to alter the traversal behavior are required.self
- a Path (that happens to be a folder/directory)closure
- the Closure to invoke on each file/directory and optionally returning a FileVisitResult
value
which can be used to control subsequent processingFileNotFoundException
- if the given directory does not existIllegalArgumentException
- if the provided Path object does not represent a directoryIOException
traverse(Path, java.util.Map, groovy.lang.Closure)
@Deprecated public static void traverse(Path self, Map<String,Object> options) throws IOException
traverse(Path, java.util.Map, groovy.lang.Closure)
allowing the 'visit' closure
to be included in the options Map rather than as a parameter.self
- a Path (that happens to be a folder/directory)options
- a Map of options to alter the traversal behaviorFileNotFoundException
- if the given directory does not existIllegalArgumentException
- if the provided Path object does not represent a directory or illegal filter combinations are suppliedIOException
traverse(Path, java.util.Map, groovy.lang.Closure)
@Deprecated public static void eachFileRecurse(Path self, Closure closure) throws IOException
closure
passing it the current
file (which may be a normal file or subdirectory) and then if a subdirectory was encountered,
recursively processing the subdirectory.self
- a Path (that happens to be a folder/directory)closure
- a ClosureFileNotFoundException
- if the given directory does not existIllegalArgumentException
- if the provided Path object does not represent a directoryIOException
eachFileRecurse(Path, groovy.io.FileType, groovy.lang.Closure)
@Deprecated public static void eachDirRecurse(Path self, Closure closure) throws IOException
closure
passing it the current
subdirectory and then recursively processing that subdirectory.
Regular files are ignored during traversal.self
- a Path (that happens to be a folder/directory)closure
- a closureFileNotFoundException
- if the given directory does not existIllegalArgumentException
- if the provided Path object does not represent a directoryIOException
eachFileRecurse(Path, groovy.io.FileType, groovy.lang.Closure)
@Deprecated public static void eachFileMatch(Path self, FileType fileType, Object nameFilter, Closure closure) throws IOException
DefaultGroovyMethods.isCase(Object, Object)
method to determine if a match occurs. This method can be used
with different kinds of filters like regular expressions, classes, ranges etc.
Both regular files and subdirectories may be candidates for matching depending
on the value of fileType.
// collect names of files in baseDir matching supplied regex pattern import static groovy.io.FileType.* def names = [] baseDir.eachFileMatch FILES, ~/foo\d\.txt/, { names<<
it.name } assert names == ['foo1.txt', 'foo2.txt'] // remove all *.bak files in baseDir baseDir.eachFileMatch FILES, ~/.*\.bak/, { Path bak->
bak.delete() } // print out files > 4K in size from baseDir baseDir.eachFileMatch FILES, { new Path(baseDir, it).size()>
4096 }, { println "$it.name ${it.size()}" }
self
- a Path (that happens to be a folder/directory)fileType
- whether normal files or directories or both should be processednameFilter
- the filter to perform on the name of the file/directory (using the DefaultGroovyMethods.isCase(Object, Object)
method)closure
- the closure to invokeFileNotFoundException
- if the given directory does not existIllegalArgumentException
- if the provided Path object does not represent a directoryIOException
@Deprecated public static void eachFileMatch(Path self, Object nameFilter, Closure closure) throws IOException
DefaultGroovyMethods.isCase(Object, Object)
method to determine if a match occurs. This method can be used
with different kinds of filters like regular expressions, classes, ranges etc.
Both regular files and subdirectories are matched.self
- a Path (that happens to be a folder/directory)nameFilter
- the nameFilter to perform on the name of the file (using the DefaultGroovyMethods.isCase(Object, Object)
method)closure
- the closure to invokeFileNotFoundException
- if the given directory does not existIllegalArgumentException
- if the provided Path object does not represent a directoryIOException
eachFileMatch(Path, groovy.io.FileType, Object, groovy.lang.Closure)
@Deprecated public static void eachDirMatch(Path self, Object nameFilter, Closure closure) throws IOException
DefaultGroovyMethods.isCase(java.lang.Object, java.lang.Object)
method to determine if a match occurs. This method can be used
with different kinds of filters like regular expressions, classes, ranges etc.
Only subdirectories are matched; regular files are ignored.self
- a Path (that happens to be a folder/directory)nameFilter
- the nameFilter to perform on the name of the directory (using the DefaultGroovyMethods.isCase(Object, Object)
method)closure
- the closure to invokeFileNotFoundException
- if the given directory does not existIllegalArgumentException
- if the provided Path object does not represent a directoryIOException
eachFileMatch(Path, groovy.io.FileType, Object, groovy.lang.Closure)
@Deprecated public static boolean deleteDir(Path self)
The method returns
self
- a Path@Deprecated public static boolean renameTo(Path self, String newPathName)
self
- a PathnewPathName
- The new pathname for the named filetrue
if and only if the renaming succeeded;
false
otherwise@Deprecated public static boolean renameTo(Path self, URI newPathName)
self
- a PathnewPathName
- The new target path specified as a URI objecttrue
if and only if the renaming succeeded;
false
otherwise@Deprecated public static Path asWritable(Path self)
Writable
.self
- a Path@Deprecated public static <T> T asType(Path path, Class<T> c)
Writable
or delegates to default
DefaultGroovyMethods.asType(Object, Class)
.path
- a Pathc
- the desired class@Deprecated public static Path asWritable(Path self, String encoding)
self
- a Pathencoding
- the encoding to be used when reading the file's contents@Deprecated public static BufferedReader newReader(Path self) throws IOException
self
- a PathIOException
- if an IOException occurs.@Deprecated public static BufferedReader newReader(Path self, String charset) throws IOException
self
- a Pathcharset
- the charset for this PathFileNotFoundException
- if the Path was not foundUnsupportedEncodingException
- if the encoding specified is not supportedIOException
@Deprecated public static <T> T withReader(Path self, Closure<T> closure) throws IOException
self
- a file objectclosure
- a closureIOException
- if an IOException occurs.@Deprecated public static <T> T withReader(Path self, String charset, Closure<T> closure) throws IOException
self
- a file objectcharset
- the charset for this input streamclosure
- a closureIOException
- if an IOException occurs.@Deprecated public static BufferedOutputStream newOutputStream(Path self) throws IOException
self
- a file objectIOException
- if an IOException occurs.@Deprecated public static DataOutputStream newDataOutputStream(Path self) throws IOException
self
- a file objectIOException
- if an IOException occurs.@Deprecated public static Object withOutputStream(Path self, Closure closure) throws IOException
self
- a Pathclosure
- a closureIOException
- if an IOException occurs.IOGroovyMethods.withStream(java.io.OutputStream, groovy.lang.Closure)
@Deprecated public static Object withInputStream(Path self, Closure closure) throws IOException
self
- a Pathclosure
- a closureIOException
- if an IOException occurs.IOGroovyMethods.withStream(java.io.InputStream, groovy.lang.Closure)
@Deprecated public static <T> T withDataOutputStream(Path self, Closure<T> closure) throws IOException
self
- a Pathclosure
- a closureIOException
- if an IOException occurs.IOGroovyMethods.withStream(java.io.OutputStream, groovy.lang.Closure)
@Deprecated public static <T> T withDataInputStream(Path self, Closure<T> closure) throws IOException
self
- a Pathclosure
- a closureIOException
- if an IOException occurs.IOGroovyMethods.withStream(java.io.InputStream, groovy.lang.Closure)
@Deprecated public static BufferedWriter newWriter(Path self) throws IOException
self
- a PathIOException
- if an IOException occurs.@Deprecated public static BufferedWriter newWriter(Path self, boolean append) throws IOException
self
- a Pathappend
- true if data should be appended to the fileIOException
- if an IOException occurs.@Deprecated public static BufferedWriter newWriter(Path self, String charset, boolean append) throws IOException
self
- a Pathcharset
- the name of the encoding used to write in this fileappend
- true if in append modeIOException
- if an IOException occurs.@Deprecated public static BufferedWriter newWriter(Path self, String charset, boolean append, boolean writeBom) throws IOException
self
- a Pathcharset
- the name of the encoding used to write in this fileappend
- true if in append modewriteBom
- whether to write a BOMIOException
- if an IOException occurs.@Deprecated public static BufferedWriter newWriter(Path self, String charset) throws IOException
self
- a Pathcharset
- the name of the encoding used to write in this fileIOException
- if an IOException occurs.@Deprecated public static <T> T withWriter(Path self, Closure<T> closure) throws IOException
self
- a Pathclosure
- a closureIOException
- if an IOException occurs.@Deprecated public static <T> T withWriter(Path self, String charset, Closure<T> closure) throws IOException
self
- a Pathcharset
- the charset usedclosure
- a closureIOException
- if an IOException occurs.@Deprecated public static <T> T withWriter(Path self, String charset, boolean writeBom, Closure<T> closure) throws IOException
writeBom
is true
, and the file doesn't already exist, the requisite
byte order mark is written to the stream when the writer is created.self
- a Pathcharset
- the charset usedwriteBom
- whether to write the BOMclosure
- a closureIOException
- if an IOException occurs.@Deprecated public static <T> T withWriterAppend(Path self, String charset, Closure<T> closure) throws IOException
self
- a Pathcharset
- the charset usedclosure
- a closureIOException
- if an IOException occurs.@Deprecated public static <T> T withWriterAppend(Path self, String charset, boolean writeBom, Closure<T> closure) throws IOException
writeBom
is true
, and the file doesn't already exist,
the requisite byte order mark is written to the stream when the writer is created.self
- a Pathcharset
- the charset usedwriteBom
- whether to write the BOMclosure
- a closureIOException
- if an IOException occurs.@Deprecated public static <T> T withWriterAppend(Path self, Closure<T> closure) throws IOException
self
- a Pathclosure
- a closureIOException
- if an IOException occurs.@Deprecated public static PrintWriter newPrintWriter(Path self) throws IOException
self
- a PathIOException
- if an IOException occurs.@Deprecated public static PrintWriter newPrintWriter(Path self, String charset) throws IOException
self
- a Pathcharset
- the charsetIOException
- if an IOException occurs.@Deprecated public static <T> T withPrintWriter(Path self, Closure<T> closure) throws IOException
self
- a Pathclosure
- the closure to invoke with the PrintWriterIOException
- if an IOException occurs.@Deprecated public static <T> T withPrintWriter(Path self, String charset, Closure<T> closure) throws IOException
self
- a Pathcharset
- the charsetclosure
- the closure to invoke with the PrintWriterIOException
- if an IOException occurs.@Deprecated public static BufferedInputStream newInputStream(Path self) throws IOException
self
- a PathFileNotFoundException
- if the file is not found.IOException
@Deprecated public static DataInputStream newDataInputStream(Path self) throws IOException
self
- a PathFileNotFoundException
- if the file is not found.IOException
@Deprecated public static void eachByte(Path self, Closure closure) throws IOException
self
- a Pathclosure
- a closureIOException
- if an IOException occurs.IOGroovyMethods.eachByte(java.io.InputStream, groovy.lang.Closure)
@Deprecated public static void eachByte(Path self, int bufferLen, Closure closure) throws IOException
self
- a PathbufferLen
- the length of the buffer to use.closure
- a 2 parameter closure which is passed the byte[] and a number of bytes successfully read.IOException
- if an IOException occurs.IOGroovyMethods.eachByte(java.io.InputStream, int, groovy.lang.Closure)
@Deprecated public static Writable filterLine(Path self, Closure closure) throws IOException
self
- a Pathclosure
- a closure which returns a boolean indicating to filter
the line or notIOException
- if self
is not readableIOGroovyMethods.filterLine(java.io.Reader, groovy.lang.Closure)
@Deprecated public static Writable filterLine(Path self, String charset, Closure closure) throws IOException
self
- a Pathcharset
- opens the file with a specified charsetclosure
- a closure which returns a boolean indicating to filter
the line or notIOException
- if an IOException occursIOGroovyMethods.filterLine(java.io.Reader, groovy.lang.Closure)
@Deprecated public static void filterLine(Path self, Writer writer, Closure closure) throws IOException
self
- a Pathwriter
- a writer destination to write filtered lines toclosure
- a closure which takes each line as a parameter and returns
true
if the line should be written to this writer.IOException
- if self
is not readableIOGroovyMethods.filterLine(java.io.Reader, java.io.Writer, groovy.lang.Closure)
@Deprecated public static void filterLine(Path self, Writer writer, String charset, Closure closure) throws IOException
self
- a Pathwriter
- a writer destination to write filtered lines tocharset
- opens the file with a specified charsetclosure
- a closure which takes each line as a parameter and returns
true
if the line should be written to this writer.IOException
- if an IO error occursIOGroovyMethods.filterLine(java.io.Reader, java.io.Writer, groovy.lang.Closure)
@Deprecated public static byte[] readBytes(Path self) throws IOException
self
- a PathIOException
- if an IOException occurs.@Deprecated public static <T> T withCloseable(Closeable self, Closure<T> action) throws IOException
IOException
IOGroovyMethods.withCloseable(java.io.Closeable, groovy.lang.Closure)