This class defines new groovy methods for Readers, Writers, InputStreams and
OutputStreams which appear on normal JDK classes inside the Groovy environment.
Static methods are used with the first parameter being the destination class,
i.e. 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.
| Type | Name and description |
|---|---|
static void |
append(File file, Object text)Append the text at the end of the File. |
static void |
append(File file, Reader reader)Append the text supplied by the Writer at the end of the File. |
static void |
append(File file, Writer writer)Append the text supplied by the Writer at the end of the File. |
static void |
append(File file, byte[] bytes)Append bytes to the end of a File. |
static void |
append(File self, InputStream stream)Append binary data to the file. |
static void |
append(File file, Object text, String charset)Append the text at the end of the File, using a specified encoding. |
static void |
append(File file, Writer writer, String charset)Append the text supplied by the Writer at the end of the File, using a specified encoding. |
static void |
append(File file, Reader reader, String charset)Append the text supplied by the Reader at the end of the File, using a specified encoding. |
static Object |
asType(File f, Class c) |
static File |
asWritable(File file) |
static File |
asWritable(File file, String encoding)Allows a file to return a Writable implementation that can output itself to a Writer stream. |
static boolean |
deleteDir(File self)Deletes a directory with all contained files and subdirectories. |
static long |
directorySize(File self)Calculates directory size as total size of all its files, recursively. |
static void |
eachByte(File self, Closure closure) |
static void |
eachByte(File self, int bufferLen, Closure closure) |
static void |
eachByte(URL url, Closure closure) |
static void |
eachByte(URL url, int bufferLen, Closure closure) |
static void |
eachDir(File self, Closure closure)Invokes the closure for each subdirectory in this directory, ignoring regular files. |
static void |
eachDirMatch(File self, Object nameFilter, Closure closure)Invokes the closure for each subdirectory whose name (dir.name) matches the given nameFilter in the given directory - calling the DefaultGroovyMethods.isCase method to determine if a match occurs. |
static void |
eachDirRecurse(File self, Closure closure)Invokes the closure for each descendant directory of this directory. |
static void |
eachFile(File self, FileType fileType, Closure closure)Invokes the closure for each 'child' file in this 'parent' folder/directory. |
static void |
eachFile(File self, Closure closure)Invokes the closure for each 'child' file in this 'parent' folder/directory. |
static void |
eachFileMatch(File self, FileType fileType, Object nameFilter, Closure closure)Invokes the closure for each file whose name (file.name) matches the given nameFilter in the given directory - calling the DefaultGroovyMethods.isCase method to determine if a match occurs. |
static void |
eachFileMatch(File self, Object nameFilter, Closure closure)Invokes the closure for each file whose name (file.name) matches the given nameFilter in the given directory - calling the DefaultGroovyMethods.isCase method to determine if a match occurs. |
static void |
eachFileRecurse(File self, FileType fileType, Closure closure)Invokes the closure for each descendant file in this directory. |
static void |
eachFileRecurse(File self, Closure closure)Invokes the closure for each descendant file in this directory. |
static Object |
eachLine(File self, Closure closure)Iterates through this file line by line. |
static Object |
eachLine(File self, String charset, Closure closure)Iterates through this file line by line. |
static Object |
eachLine(File self, int firstLine, Closure closure)Iterates through this file line by line. |
static Object |
eachLine(File self, String charset, int firstLine, Closure closure)Iterates through this file line by line. |
static Object |
eachLine(URL url, Closure closure)Iterates through the lines read from the URL's associated input stream passing each line to the given 1 or 2 arg closure. |
static Object |
eachLine(URL url, int firstLine, Closure closure)Iterates through the lines read from the URL's associated input stream passing each line to the given 1 or 2 arg closure. |
static Object |
eachLine(URL url, String charset, Closure closure)Iterates through the lines read from the URL's associated input stream passing each line to the given 1 or 2 arg closure. |
static Object |
eachLine(URL url, String charset, int firstLine, Closure closure)Iterates through the lines read from the URL's associated input stream passing each line to the given 1 or 2 arg closure. |
static void |
eachObject(File self, Closure closure)Iterates through the given file object by object. |
static Writable |
filterLine(File self, Closure closure) |
static Writable |
filterLine(File self, String charset, Closure closure) |
static void |
filterLine(File self, Writer writer, Closure closure) |
static void |
filterLine(File self, Writer writer, String charset, Closure closure) |
static Writable |
filterLine(URL self, Closure predicate) |
static Writable |
filterLine(URL self, String charset, Closure predicate) |
static void |
filterLine(URL self, Writer writer, Closure predicate) |
static void |
filterLine(URL self, Writer writer, String charset, Closure predicate) |
static byte[] |
getBytes(File file)Read the content of the File and returns it as a byte[]. |
static byte[] |
getBytes(URL url)Read the content of this URL and returns it as a byte[]. |
static String |
getText(File file, String charset)Read the content of the File using the specified encoding and return it as a String. |
static String |
getText(File file)Read the content of the File and returns it as a String. |
static String |
getText(URL url)Read the content of this URL and returns it as a String. |
static String |
getText(URL url, Map parameters)Read the content of this URL and returns it as a String. |
static String |
getText(URL url, String charset)Read the data from this URL and return it as a String. |
static String |
getText(URL url, Map parameters, String charset)Read the data from this URL and return it as a String. |
static File |
leftShift(File file, Object text)Write the text to the File. |
static File |
leftShift(File file, byte[] bytes)Write bytes to a File. |
static File |
leftShift(File file, InputStream data)Append binary data to the file. |
static DataInputStream |
newDataInputStream(File file) |
static DataOutputStream |
newDataOutputStream(File file) |
static BufferedInputStream |
newInputStream(File file) |
static BufferedInputStream |
newInputStream(URL url)Creates a buffered input stream for this URL. |
static BufferedInputStream |
newInputStream(URL url, Map parameters) |
static ObjectInputStream |
newObjectInputStream(File file)Create an object input stream for this file. |
static ObjectInputStream |
newObjectInputStream(File file, ClassLoader classLoader)Create an object input stream for this file using the given class loader. |
static ObjectOutputStream |
newObjectOutputStream(File file)Create an object output stream for this file. |
static BufferedOutputStream |
newOutputStream(File file) |
static PrintWriter |
newPrintWriter(File file) |
static PrintWriter |
newPrintWriter(File file, String charset) |
static BufferedReader |
newReader(File file) |
static BufferedReader |
newReader(File file, String charset) |
static BufferedReader |
newReader(URL url) |
static BufferedReader |
newReader(URL url, Map parameters) |
static BufferedReader |
newReader(URL url, String charset) |
static BufferedReader |
newReader(URL url, Map parameters, String charset) |
static BufferedWriter |
newWriter(File file) |
static BufferedWriter |
newWriter(File file, boolean append) |
static BufferedWriter |
newWriter(File file, String charset, boolean append) |
static BufferedWriter |
newWriter(File file, String charset)Creates a buffered writer for this file, writing data using the given encoding. |
static byte[] |
readBytes(File file) |
static List |
readLines(File file)Reads the file into a list of Strings, with one item for each line. |
static List |
readLines(File file, String charset)Reads the file into a list of Strings, with one item for each line. |
static List |
readLines(URL self)Reads the URL contents into a list, with one element for each line. |
static List |
readLines(URL self, String charset)Reads the URL contents into a list, with one element for each line. |
static boolean |
renameTo(File self, String newPathName)Renames the file. |
static void |
setBytes(File file, byte[] bytes)Write the bytes from the byte array to the File. |
static void |
setText(File file, String text)Synonym for write(text) allowing file.text = 'foo'. |
static void |
setText(File file, String text, String charset)Synonym for write(text, charset) allowing:
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'
|
static long |
size(File self)Provide the standard Groovy size() method for File. |
static Object |
splitEachLine(File self, String regex, Closure closure)Iterates through this file line by line, splitting each line using the given regex separator. |
static Object |
splitEachLine(File self, Pattern pattern, Closure closure)Iterates through this file line by line, splitting each line using the given separator Pattern. |
static Object |
splitEachLine(File self, String regex, String charset, Closure closure)Iterates through this file line by line, splitting each line using the given regex separator. |
static Object |
splitEachLine(File self, Pattern pattern, String charset, Closure closure)Iterates through this file line by line, splitting each line using the given regex separator Pattern. |
static Object |
splitEachLine(URL self, String regex, Closure closure)Iterates through the input stream associated with this URL line by line, splitting each line using the given regex separator. |
static Object |
splitEachLine(URL self, Pattern pattern, Closure closure)Iterates through the input stream associated with this URL line by line, splitting each line using the given regex separator Pattern. |
static Object |
splitEachLine(URL self, String regex, String charset, Closure closure)Iterates through the input stream associated with this URL line by line, splitting each line using the given regex separator. |
static Object |
splitEachLine(URL self, Pattern pattern, String charset, Closure closure)Iterates through the input stream associated with this URL line by line, splitting each line using the given regex separator Pattern. |
static URI |
toURI(CharSequence self)Transforms a CharSequence representing a URI into a URI object. |
static URI |
toURI(String self) |
static URL |
toURL(CharSequence self) |
static URL |
toURL(String self) |
static void |
traverse(File self, Map options, Closure closure)Invokes closure for each descendant file in this directory tree.
|
static void |
traverse(File self, Closure closure)Invokes the closure for each descendant file in this directory tree. |
static void |
traverse(File self, Map options)Invokes the closure specified with key 'visit' in the options Map for each descendant file in this directory tree. |
static Object |
withDataInputStream(File file, Closure closure) |
static Object |
withDataOutputStream(File file, Closure closure) |
static Object |
withInputStream(File file, Closure closure) |
static Object |
withInputStream(URL url, Closure closure) |
static Object |
withObjectInputStream(File file, Closure closure)Create a new ObjectInputStream for this file and pass it to the closure. |
static Object |
withObjectInputStream(File file, ClassLoader classLoader, Closure closure)Create a new ObjectInputStream for this file associated with the given class loader and pass it to the closure. |
static Object |
withObjectOutputStream(File file, Closure closure)Create a new ObjectOutputStream for this file and then pass it to the closure. |
static Object |
withOutputStream(File file, Closure closure) |
static Object |
withPrintWriter(File file, Closure closure) |
static Object |
withPrintWriter(File file, String charset, Closure closure) |
static Object |
withReader(File file, Closure closure) |
static Object |
withReader(File file, String charset, Closure closure) |
static Object |
withReader(URL url, Closure closure) |
static Object |
withReader(URL url, String charset, Closure closure) |
static Object |
withWriter(File file, Closure closure)Creates a new BufferedWriter for this file, passes it to the closure, and ensures the stream is flushed and closed after the closure returns. |
static Object |
withWriter(File file, String charset, Closure closure) |
static Object |
withWriterAppend(File file, String charset, Closure closure) |
static Object |
withWriterAppend(File file, Closure closure) |
static void |
write(File file, String text)Write the text to the File. |
static void |
write(File file, String text, String charset)Write the text to the File, using the specified encoding. |
| Methods inherited from class | Name |
|---|---|
class DefaultGroovyMethodsSupport |
cloneSimilarCollection, cloneSimilarMap, closeQuietly, closeWithWarning, createSimilarArray, createSimilarCollection, createSimilarCollection, createSimilarList, createSimilarMap, createSimilarOrDefaultCollection, createSimilarSet, normaliseIndex, sameType, subListBorders, subListBorders |
class Object |
wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll |
Append the text at the end of the File.
file - a Filetext - the text to append at the end of the FileAppend the text supplied by the Writer at the end of the File.
file - a Filereader - the Reader supplying the text to append at the end of the FileAppend the text supplied by the Writer at the end of the File.
file - a Filewriter - the Writer supplying the text to append at the end of the FileAppend bytes to the end of a File.
file - a Filebytes - the byte array to append to the end of the FileAppend binary data to the file. It will not be interpreted as text.
self - a Filestream - stream to read data from.Append the text at the end of the File, using a specified encoding.
file - a Filetext - the text to append at the end of the Filecharset - the charset usedAppend the text supplied by the Writer at the end of the File, using a specified encoding.
file - a Filewriter - the Writer supplying the text to append at the end of the Filecharset - the charset usedAppend the text supplied by the Reader at the end of the File, using a specified encoding.
file - a Filereader - the Reader supplying the text to append at the end of the Filecharset - the charset usedAllows a file to return a Writable implementation that can output itself to a Writer stream.
file - a Fileencoding - the encoding to be used when reading the file's contentsDeletes a directory with all contained files and subdirectories.
The method returns
self - a FileCalculates directory size as total size of all its files, recursively.
self - a file objectInvokes the closure for each subdirectory in this directory, ignoring regular files.
self - a File (that happens to be a folder/directory)closure - a closure (first parameter is the subdirectory file)Invokes the closure for each subdirectory whose name (dir.name) matches the given nameFilter in the given directory - calling the DefaultGroovyMethods.isCase 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 filenameFilter - the nameFilter to perform on the name of the directory (using the DefaultGroovyMethods.isCase method)closure - the closure to invokeInvokes the closure for each descendant directory of this directory. Sub-directories are recursively searched in a depth-first fashion. Only subdirectories are passed to the closure; regular files are ignored.
self - a directoryclosure - a closureInvokes the closure for each 'child' file in this 'parent' folder/directory. Both regular files and subfolders/subdirectories can be processed depending on the fileType enum value.
self - a file objectfileType - if normal files or directories or both should be processedclosure - the closure to invokeInvokes the closure for each 'child' file in this 'parent' folder/directory. Both regular files and subfolders/subdirectories are processed.
self - a File (that happens to be a folder/directory)closure - a closure (first parameter is the 'child' file)Invokes the closure for each file whose name (file.name) matches the given nameFilter in the given directory - calling the DefaultGroovyMethods.isCase 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/, { File bak -> bak.delete() }
// print out files > 4K in size from baseDir
baseDir.eachFileMatch FILES, { new File(baseDir, it).size() > 4096 }, { println "$it.name ${it.size()}" }
self - a filefileType - 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 method)closure - the closure to invokeInvokes the closure for each file whose name (file.name) matches the given nameFilter in the given directory - calling the DefaultGroovyMethods.isCase 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 filenameFilter - the nameFilter to perform on the name of the file (using the DefaultGroovyMethods.isCase method)closure - the closure to invokeInvokes the closure for each descendant file in this directory. Sub-directories are recursively searched in a depth-first fashion. Both regular files and subdirectories may be passed to the closure depending on the value of fileType.
self - a file objectfileType - if normal files or directories or both should be processedclosure - the closure to invoke on each fileInvokes the closure for each descendant file in this directory. Sub-directories are recursively searched in a depth-first fashion. Both regular files and subdirectories are passed to the closure.
self - a Fileclosure - a closureIterates through this file line by line. Each line is passed to the given 1 or 2 arg closure. The file is read using a reader which is closed before this method returns.
self - a Fileclosure - a closure (arg 1 is line, optional arg 2 is line number starting at line 1)Iterates through this file line by line. Each line is passed to the given 1 or 2 arg closure. The file is read using a reader which is closed before this method returns.
self - a Filecharset - opens the file with a specified charsetclosure - a closure (arg 1 is line, optional arg 2 is line number starting at line 1)Iterates through this file line by line. Each line is passed to the given 1 or 2 arg closure. The file is read using a reader which is closed before this method returns.
self - a FilefirstLine - 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)Iterates through this file line by line. Each line is passed to the given 1 or 2 arg closure. The file is read using a reader which is closed before this method returns.
self - a Filecharset - 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)Iterates through the lines read from the URL's associated input stream passing each line to the given 1 or 2 arg closure. The stream is closed before this method returns.
url - a URL to open and readclosure - a closure to apply on each line (arg 1 is line, optional arg 2 is line number starting at line 1)Iterates through the lines read from the URL's associated input stream passing each line to the given 1 or 2 arg closure. The stream is closed before this method returns.
url - a URL to open and readfirstLine - the line number value used for the first line (default is 1, set to 0 to start counting from 0)closure - a closure to apply on each line (arg 1 is line, optional arg 2 is line number)Iterates through the lines read from the URL's associated input stream passing each line to the given 1 or 2 arg closure. The stream is closed before this method returns.
url - a URL to open and readcharset - opens the stream with a specified charsetclosure - a closure to apply on each line (arg 1 is line, optional arg 2 is line number starting at line 1)Iterates through the lines read from the URL's associated input stream passing each line to the given 1 or 2 arg closure. The stream is closed before this method returns.
url - a URL to open and readcharset - opens the stream 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 to apply on each line (arg 1 is line, optional arg 2 is line number)Iterates through the given file object by object.
self - a Fileclosure - a closureRead the content of the File and returns it as a byte[].
file - the file whose content we want to readRead the content of this URL and returns it as a byte[].
url - URL to read content fromRead the content of the File using the specified encoding and return it as a String.
file - the file whose content we want to readcharset - the charset used to read the content of the fileRead the content of the File and returns it as a String.
file - the file whose content we want to readRead the content of this URL and returns it as a String.
url - URL to read content fromRead the content of this URL and returns it as a String. The default connection parameters can be modified by adding keys to the parameters map:
url - URL to read content fromparameters - connection parametersRead the data from this URL and return it as a String. The connection stream is closed before this method returns.
url - URL to read content fromcharset - opens the stream with a specified charsetRead the data from this URL and return it as a String. The connection stream is closed before this method returns.
url - URL to read content fromparameters - connection parameterscharset - opens the stream with a specified charsetWrite the text to the File.
file - a Filetext - the text to write to the FileWrite bytes to a File.
file - a Filebytes - the byte array to append to the end of the FileAppend binary data to the file. See append(java.io.File, java.io.InputStream)
file - a Filedata - an InputStream of data to write to the fileCreates a buffered input stream for this URL.
url - a URLCreate an object input stream for this file.
file - a fileCreate an object input stream for this file using the given class loader.
file - a fileclassLoader - the class loader to use when loading the classCreate an object output stream for this file.
file - a fileCreates a buffered writer for this file, writing data using the given encoding.
file - a Filecharset - the name of the encoding used to write in this fileReads the file into a list of Strings, with one item for each line.
file - a FileReads the file into a list of Strings, with one item for each line.
file - a Filecharset - opens the file with a specified charsetReads the URL contents into a list, with one element for each line.
self - a URLReads the URL contents into a list, with one element for each line.
self - a URLcharset - opens the URL with a specified charsetRenames the file. It's a shortcut for File.renameTo
self - a FilenewPathName - The new pathname for the named filetrue if and only if the renaming succeeded;
false otherwiseWrite the bytes from the byte array to the File.
file - the file to write tobytes - the byte[] to write to the fileSynonym for write(text) allowing file.text = 'foo'.
file - a Filetext - the text to write to the FileSynonym for write(text, charset) allowing:
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'
file - A Filecharset - The charset used when writing to the filetext - The text to write to the File Provide the standard Groovy size() method for File.
self - a file objectIterates through this file line by line, splitting each line using the given regex separator. For each line, the given closure is called with a single parameter being the list of strings computed by splitting the line around matches of the given regular expression. Finally the resources used for processing the file are closed.
self - a Fileregex - the delimiting regular expressionclosure - a closureIterates through this file line by line, splitting each line using the given separator Pattern. For each line, the given closure is called with a single parameter being the list of strings computed by splitting the line around matches of the given regular expression Pattern. Finally the resources used for processing the file are closed.
self - a Filepattern - the regular expression Pattern for the delimiterclosure - a closureIterates through this file line by line, splitting each line using the given regex separator. For each line, the given closure is called with a single parameter being the list of strings computed by splitting the line around matches of the given regular expression. Finally the resources used for processing the file are closed.
self - a Fileregex - the delimiting regular expressioncharset - opens the file with a specified charsetclosure - a closureIterates through this file line by line, splitting each line using the given regex separator Pattern. For each line, the given closure is called with a single parameter being the list of strings computed by splitting the line around matches of the given regular expression. Finally the resources used for processing the file are closed.
self - a Filepattern - the regular expression Pattern for the delimitercharset - opens the file with a specified charsetclosure - a closureIterates through the input stream associated with this URL line by line, splitting each line using the given regex separator. For each line, the given closure is called with a single parameter being the list of strings computed by splitting the line around matches of the given regular expression. Finally the resources used for processing the URL are closed.
self - a URL to open and readregex - the delimiting regular expressionclosure - a closureIterates through the input stream associated with this URL line by line, splitting each line using the given regex separator Pattern. For each line, the given closure is called with a single parameter being the list of strings computed by splitting the line around matches of the given regular expression. Finally the resources used for processing the URL are closed.
self - a URL to open and readpattern - the regular expression Pattern for the delimiterclosure - a closureIterates through the input stream associated with this URL line by line, splitting each line using the given regex separator. For each line, the given closure is called with a single parameter being the list of strings computed by splitting the line around matches of the given regular expression. Finally the resources used for processing the URL are closed.
self - a URL to open and readregex - the delimiting regular expressioncharset - opens the file with a specified charsetclosure - a closureIterates through the input stream associated with this URL line by line, splitting each line using the given regex separator Pattern. For each line, the given closure is called with a single parameter being the list of strings computed by splitting the line around matches of the given regular expression. Finally the resources used for processing the URL are closed.
self - a URL to open and readpattern - the regular expression Pattern for the delimitercharset - opens the file with a specified charsetclosure - a closureTransforms a CharSequence representing a URI into a URI object.
self - the CharSequence representing a URI Invokes closure for each descendant file in this directory tree.
Sub-directories are recursively traversed as found.
The traversal can be adapted by providing various options in the options Map according
to the following keys:
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 Fileoptions - 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 processingInvokes the closure for each descendant file in this directory tree. Sub-directories are recursively traversed in a depth-first fashion. Convenience method for traverse(java.io.File, java.util.Map, groovy.lang.Closure) when no options to alter the traversal behavior are required.
self - a Fileclosure - the Closure to invoke on each file/directory and optionally returning a FileVisitResult value
which can be used to control subsequent processingInvokes the closure specified with key 'visit' in the options Map for each descendant file in this directory tree. Convenience method for traverse(java.io.File, java.util.Map, groovy.lang.Closure) allowing the 'visit' closure to be included in the options Map rather than as a parameter.
self - a Fileoptions - a Map of options to alter the traversal behaviorCreate a new ObjectInputStream for this file and pass it to the closure. This method ensures the stream is closed after the closure returns.
file - a Fileclosure - a closureCreate a new ObjectInputStream for this file associated with the given class loader and pass it to the closure. This method ensures the stream is closed after the closure returns.
file - a FileclassLoader - the class loader to use when loading the classclosure - a closureCreate a new ObjectOutputStream for this file and then pass it to the closure. This method ensures the stream is closed after the closure returns.
file - a Fileclosure - a closureCreates a new BufferedWriter for this file, passes it to the closure, and ensures the stream is flushed and closed after the closure returns.
file - a Fileclosure - a closureWrite the text to the File.
file - a Filetext - the text to write to the File