Package org.codehaus.groovy.runtime
Class NioGroovyMethods
java.lang.Object
org.codehaus.groovy.runtime.DefaultGroovyMethodsSupport
org.codehaus.groovy.runtime.NioGroovyMethods
@Deprecated public class NioGroovyMethods extends DefaultGroovyMethodsSupport
Deprecated.
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.-
Constructor Summary
Constructors Constructor Description NioGroovyMethods()
Deprecated. -
Method Summary
Modifier and Type Method Description static void
append(Path self, byte[] bytes)
Deprecated.static void
append(Path self, InputStream stream)
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 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 <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, int bufferLen, Closure closure)
Deprecated.static void
eachByte(Path self, 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, FileType fileType, Closure closure)
Deprecated.static void
eachFile(Path self, 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, FileType fileType, Closure closure)
Deprecated.static void
eachFileRecurse(Path self, Closure closure)
Deprecated.static <T> T
eachLine(Path self, int firstLine, Closure<T> closure)
Deprecated.static <T> T
eachLine(Path self, Closure<T> closure)
Deprecated.static <T> T
eachLine(Path self, String charset, int firstLine, Closure<T> closure)
Deprecated.static <T> T
eachLine(Path self, String charset, Closure<T> closure)
Deprecated.static void
eachObject(Path self, Closure closure)
Deprecated.static Writable
filterLine(Path self, 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 Writable
filterLine(Path self, 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, String regex, Closure<T> closure)
Deprecated.static <T> T
splitEachLine(Path self, String regex, String charset, Closure<T> closure)
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 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 path, Closure<T> closure)
Deprecated.static <T> T
withObjectInputStream(Path self, ClassLoader classLoader, 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.Methods inherited from class org.codehaus.groovy.runtime.DefaultGroovyMethodsSupport
cloneSimilarCollection, cloneSimilarMap, closeQuietly, closeWithWarning, createSimilarArray, createSimilarCollection, createSimilarCollection, createSimilarCollection, createSimilarList, createSimilarMap, createSimilarOrDefaultCollection, createSimilarQueue, createSimilarSet, normaliseIndex, sameType, subListBorders, subListBorders, writeUTF16BomIfRequired, writeUTF16BomIfRequired, writeUTF16BomIfRequired, writeUTF16BomIfRequired
-
Constructor Details
-
NioGroovyMethods
public NioGroovyMethods()Deprecated.
-
-
Method Details
-
size
Deprecated.Provide the standard Groovysize()
method forPath
.- Parameters:
self
- aPath
object- Returns:
- the file's size (length)
- Throws:
IOException
- Since:
- 2.3.0
-
newObjectOutputStream
Deprecated.Create an object output stream for this path.- Parameters:
self
- aPath
object- Returns:
- an object output stream
- Throws:
IOException
- if an IOException occurs.- Since:
- 2.3.0
-
withObjectOutputStream
@Deprecated public static <T> T withObjectOutputStream(Path self, Closure<T> closure) throws IOExceptionDeprecated.Create a new ObjectOutputStream for this path and then pass it to the closure. This method ensures the stream is closed after the closure returns.- Parameters:
self
- a Pathclosure
- a closure- Returns:
- the value returned by the closure
- Throws:
IOException
- if an IOException occurs.- Since:
- 2.3.0
- See Also:
IOGroovyMethods.withStream(java.io.OutputStream, groovy.lang.Closure)
-
newObjectInputStream
Deprecated.Create an object input stream for this file.- Parameters:
self
- aPath
object- Returns:
- an object input stream
- Throws:
IOException
- if an IOException occurs.- Since:
- 2.3.0
-
newObjectInputStream
@Deprecated public static ObjectInputStream newObjectInputStream(Path self, ClassLoader classLoader) throws IOExceptionDeprecated.Create an object input stream for this path using the given class loader.- Parameters:
self
- aPath
objectclassLoader
- the class loader to use when loading the class- Returns:
- an object input stream
- Throws:
IOException
- if an IOException occurs.- Since:
- 2.3.0
-
eachObject
@Deprecated public static void eachObject(Path self, Closure closure) throws IOException, ClassNotFoundExceptionDeprecated.Iterates through the given file object by object.- Parameters:
self
- aPath
objectclosure
- a closure- Throws:
IOException
- if an IOException occurs.ClassNotFoundException
- if the class is not found.- Since:
- 2.3.0
- See Also:
IOGroovyMethods.eachObject(java.io.ObjectInputStream, groovy.lang.Closure)
-
withObjectInputStream
@Deprecated public static <T> T withObjectInputStream(Path path, Closure<T> closure) throws IOExceptionDeprecated.Create a new ObjectInputStream for this file and pass it to the closure. This method ensures the stream is closed after the closure returns.- Parameters:
path
- a Pathclosure
- a closure- Returns:
- the value returned by the closure
- Throws:
IOException
- if an IOException occurs.- Since:
- 2.3.0
- See Also:
IOGroovyMethods.withStream(java.io.InputStream, groovy.lang.Closure)
-
withObjectInputStream
@Deprecated public static <T> T withObjectInputStream(Path self, ClassLoader classLoader, Closure<T> closure) throws IOExceptionDeprecated.Create 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.- Parameters:
self
- a PathclassLoader
- the class loader to use when loading the classclosure
- a closure- Returns:
- the value returned by the closure
- Throws:
IOException
- if an IOException occurs.- Since:
- 2.3.0
- See Also:
IOGroovyMethods.withStream(java.io.InputStream, groovy.lang.Closure)
-
eachLine
Deprecated.Iterates through this path 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.- Parameters:
self
- a Pathclosure
- a closure (arg 1 is line, optional arg 2 is line number starting at line 1)- Returns:
- the last value returned by the closure
- Throws:
IOException
- if an IOException occurs.- Since:
- 2.3.0
- See Also:
eachLine(Path, int, groovy.lang.Closure)
-
eachLine
@Deprecated public static <T> T eachLine(Path self, String charset, Closure<T> closure) throws IOExceptionDeprecated.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.- Parameters:
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)- Returns:
- the last value returned by the closure
- Throws:
IOException
- if an IOException occurs.- Since:
- 2.3.0
- See Also:
eachLine(Path, String, int, groovy.lang.Closure)
-
eachLine
@Deprecated public static <T> T eachLine(Path self, int firstLine, Closure<T> closure) throws IOExceptionDeprecated.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.- Parameters:
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)- Returns:
- the last value returned by the closure
- Throws:
IOException
- if an IOException occurs.- Since:
- 2.3.0
- See Also:
IOGroovyMethods.eachLine(java.io.Reader, int, groovy.lang.Closure)
-
eachLine
@Deprecated public static <T> T eachLine(Path self, String charset, int firstLine, Closure<T> closure) throws IOExceptionDeprecated.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.- Parameters:
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)- Returns:
- the last value returned by the closure
- Throws:
IOException
- if an IOException occurs.- Since:
- 2.3.0
- See Also:
IOGroovyMethods.eachLine(java.io.Reader, int, groovy.lang.Closure)
-
splitEachLine
@Deprecated public static <T> T splitEachLine(Path self, String regex, Closure<T> closure) throws IOExceptionDeprecated.Iterates 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.- Parameters:
self
- a Pathregex
- the delimiting regular expressionclosure
- a closure- Returns:
- the last value returned by the closure
- Throws:
IOException
- if an IOException occurs.PatternSyntaxException
- if the regular expression's syntax is invalid- Since:
- 2.3.0
- See Also:
IOGroovyMethods.splitEachLine(java.io.Reader, String, groovy.lang.Closure)
-
splitEachLine
@Deprecated public static <T> T splitEachLine(Path self, Pattern pattern, Closure<T> closure) throws IOExceptionDeprecated.Iterates 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.- Parameters:
self
- a Pathpattern
- the regular expression Pattern for the delimiterclosure
- a closure- Returns:
- the last value returned by the closure
- Throws:
IOException
- if an IOException occurs.- Since:
- 2.3.0
- See Also:
IOGroovyMethods.splitEachLine(java.io.Reader, java.util.regex.Pattern, groovy.lang.Closure)
-
splitEachLine
@Deprecated public static <T> T splitEachLine(Path self, String regex, String charset, Closure<T> closure) throws IOExceptionDeprecated.Iterates 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.- Parameters:
self
- a Pathregex
- the delimiting regular expressioncharset
- opens the file with a specified charsetclosure
- a closure- Returns:
- the last value returned by the closure
- Throws:
IOException
- if an IOException occurs.PatternSyntaxException
- if the regular expression's syntax is invalid- Since:
- 2.3.0
- See Also:
IOGroovyMethods.splitEachLine(java.io.Reader, String, groovy.lang.Closure)
-
splitEachLine
@Deprecated public static <T> T splitEachLine(Path self, Pattern pattern, String charset, Closure<T> closure) throws IOExceptionDeprecated.Iterates 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.- Parameters:
self
- a Pathpattern
- the regular expression Pattern for the delimitercharset
- opens the file with a specified charsetclosure
- a closure- Returns:
- the last value returned by the closure
- Throws:
IOException
- if an IOException occurs.- Since:
- 2.3.0
- See Also:
IOGroovyMethods.splitEachLine(java.io.Reader, java.util.regex.Pattern, groovy.lang.Closure)
-
readLines
Deprecated.Reads the file into a list of Strings, with one item for each line.- Parameters:
self
- a Path- Returns:
- a List of lines
- Throws:
IOException
- if an IOException occurs.- Since:
- 2.3.0
- See Also:
IOGroovyMethods.readLines(java.io.Reader)
-
readLines
Deprecated.Reads the file into a list of Strings, with one item for each line.- Parameters:
self
- a Pathcharset
- opens the file with a specified charset- Returns:
- a List of lines
- Throws:
IOException
- if an IOException occurs.- Since:
- 2.3.0
- See Also:
IOGroovyMethods.readLines(java.io.Reader)
-
getText
Deprecated.Read the content of the Path using the specified encoding and return it as a String.- Parameters:
self
- the file whose content we want to readcharset
- the charset used to read the content of the file- Returns:
- a String containing the content of the file
- Throws:
IOException
- if an IOException occurs.- Since:
- 2.3.0
-
getText
Deprecated.Read the content of the Path and returns it as a String.- Parameters:
self
- the file whose content we want to read- Returns:
- a String containing the content of the file
- Throws:
IOException
- if an IOException occurs.- Since:
- 2.3.0
-
getBytes
Deprecated.Read the content of the Path and returns it as a byte[].- Parameters:
self
- the file whose content we want to read- Returns:
- a String containing the content of the file
- Throws:
IOException
- if an IOException occurs.- Since:
- 2.3.0
-
setBytes
Deprecated.Write the bytes from the byte array to the Path.- Parameters:
self
- the file to write tobytes
- the byte[] to write to the file- Throws:
IOException
- if an IOException occurs.- Since:
- 2.3.0
-
write
Deprecated.Write the text to the Path without writing a BOM .- Parameters:
self
- a Pathtext
- the text to write to the Path- Throws:
IOException
- if an IOException occurs.- Since:
- 2.3.0
-
write
Deprecated.Write the text to the Path. If the default charset is "UTF-16BE" or "UTF-16LE" (or an equivalent alias) andwriteBom
istrue
, the requisite byte order mark is written to the file before the text.- Parameters:
self
- a Pathtext
- the text to write to the PathwriteBom
- whether to write the BOM- Throws:
IOException
- if an IOException occurs.- Since:
- 2.5.0
-
setText
Deprecated.Synonym for write(text) allowing file.text = 'foo'.- Parameters:
self
- a Pathtext
- the text to write to the Path- Throws:
IOException
- if an IOException occurs.- Since:
- 2.3.0
- See Also:
write(Path, String)
-
setText
Deprecated.Synonym for write(text, charset) allowing:myFile.setText('some text', charset)
or with some help fromExpandoMetaClass
, you could do something like:myFile.metaClass.setText = { String s
->
delegate.setText(s, 'UTF-8') } myfile.text = 'some text'- Parameters:
self
- A Pathcharset
- The charset used when writing to the filetext
- The text to write to the Path- Throws:
IOException
- if an IOException occurs.- Since:
- 2.3.0
- See Also:
write(Path, String, String)
-
leftShift
Deprecated.Write the text to the Path.- Parameters:
self
- a Pathtext
- the text to write to the Path- Returns:
- the original file
- Throws:
IOException
- if an IOException occurs.- Since:
- 2.3.0
-
leftShift
Deprecated.Write bytes to a Path.- Parameters:
self
- a Pathbytes
- the byte array to append to the end of the Path- Returns:
- the original file
- Throws:
IOException
- if an IOException occurs.- Since:
- 2.3.0
-
leftShift
Deprecated.Append binary data to the file. Seeappend(Path, java.io.InputStream)
- Parameters:
path
- a Pathdata
- an InputStream of data to write to the file- Returns:
- the file
- Throws:
IOException
- if an IOException occurs.- Since:
- 2.3.0
-
write
Deprecated.Write the text to the Path without writing a BOM, using the specified encoding.- Parameters:
self
- a Pathtext
- the text to write to the Pathcharset
- the charset used- Throws:
IOException
- if an IOException occurs.- Since:
- 2.3.0
-
write
@Deprecated public static void write(Path self, String text, String charset, boolean writeBom) throws IOExceptionDeprecated.Write the text to the Path, using the specified encoding. If the given charset is "UTF-16BE" or "UTF-16LE" (or an equivalent alias) andwriteBom
istrue
, the requisite byte order mark is written to the file before the text.- Parameters:
self
- a Pathtext
- the text to write to the Pathcharset
- the charset usedwriteBom
- whether to write a BOM- Throws:
IOException
- if an IOException occurs.- Since:
- 2.5.0
-
append
Deprecated.Append the text at the end of the Path without writing a BOM.- Parameters:
self
- a Pathtext
- the text to append at the end of the Path- Throws:
IOException
- if an IOException occurs.- Since:
- 2.3.0
-
append
Deprecated.Append the text supplied by the Writer at the end of the File without writing a BOM.- Parameters:
file
- a Pathreader
- the Reader supplying the text to append at the end of the File- Throws:
IOException
- if an IOException occurs.- Since:
- 2.3.0
-
append
Deprecated.Append the text supplied by the Writer at the end of the File without writing a BOM.- Parameters:
file
- a Filewriter
- the Writer supplying the text to append at the end of the File- Throws:
IOException
- if an IOException occurs.- Since:
- 2.3.0
-
append
Deprecated.Append bytes to the end of a Path. It will not be interpreted as text.- Parameters:
self
- a Pathbytes
- the byte array to append to the end of the Path- Throws:
IOException
- if an IOException occurs.- Since:
- 2.3.0
-
append
Deprecated.Append binary data to the file. It will not be interpreted as text.- Parameters:
self
- a Pathstream
- stream to read data from.- Throws:
IOException
- if an IOException occurs.- Since:
- 2.3.0
-
append
Deprecated.Append the text at the end of the Path. If the default charset is "UTF-16BE" or "UTF-16LE" (or an equivalent alias) andwriteBom
istrue
, the requisite byte order mark is written to the file before the text.- Parameters:
self
- a Pathtext
- the text to append at the end of the PathwriteBom
- whether to write the BOM- Throws:
IOException
- if an IOException occurs.- Since:
- 2.5.0
-
append
Deprecated.Append the text at the end of the Path without writing a BOM, using a specified encoding.- Parameters:
self
- a Pathtext
- the text to append at the end of the Pathcharset
- the charset used- Throws:
IOException
- if an IOException occurs.- Since:
- 2.3.0
-
append
@Deprecated public static void append(Path self, Object text, String charset, boolean writeBom) throws IOExceptionDeprecated.Append the text at the end of the Path, using a specified encoding. If the given charset is "UTF-16BE" or "UTF-16LE" (or an equivalent alias),writeBom
istrue
, and the file doesn't already exist, the requisite byte order mark is written to the file before the text is appended.- Parameters:
self
- a Pathtext
- the text to append at the end of the Pathcharset
- the charset usedwriteBom
- whether to write the BOM- Throws:
IOException
- if an IOException occurs.- Since:
- 2.5.0
-
append
@Deprecated public static void append(Path file, Writer writer, boolean writeBom) throws IOExceptionDeprecated.Append the text supplied by the Writer at the end of the File, using a specified encoding. If the given charset is "UTF-16BE" or "UTF-16LE" (or an equivalent alias),writeBom
istrue
, and the file doesn't already exist, the requisite byte order mark is written to the file before the text is appended.- Parameters:
file
- a Filewriter
- the Writer supplying the text to append at the end of the FilewriteBom
- whether to write the BOM- Throws:
IOException
- if an IOException occurs.- Since:
- 2.5.0
-
append
Deprecated.Append the text supplied by the Writer at the end of the File without writing a BOM, using a specified encoding.- Parameters:
file
- a Filewriter
- the Writer supplying the text to append at the end of the Filecharset
- the charset used- Throws:
IOException
- if an IOException occurs.- Since:
- 2.3.0
-
append
@Deprecated public static void append(Path file, Writer writer, String charset, boolean writeBom) throws IOExceptionDeprecated.Append the text supplied by the Writer at the end of the File, using a specified encoding. If the given charset is "UTF-16BE" or "UTF-16LE" (or an equivalent alias),writeBom
istrue
, and the file doesn't already exist, the requisite byte order mark is written to the file before the text is appended.- Parameters:
file
- a Filewriter
- the Writer supplying the text to append at the end of the Filecharset
- the charset usedwriteBom
- whether to write the BOM- Throws:
IOException
- if an IOException occurs.- Since:
- 2.5.0
-
append
@Deprecated public static void append(Path file, Reader reader, boolean writeBom) throws IOExceptionDeprecated.Append the text supplied by the Reader at the end of the File, using a specified encoding. If the given charset is "UTF-16BE" or "UTF-16LE" (or an equivalent alias),writeBom
istrue
, and the file doesn't already exist, the requisite byte order mark is written to the file before the text is appended.- Parameters:
file
- a Filereader
- the Reader supplying the text to append at the end of the FilewriteBom
- whether to write the BOM- Throws:
IOException
- if an IOException occurs.- Since:
- 2.5.0
-
append
Deprecated.Append the text supplied by the Reader at the end of the File without writing a BOM, using a specified encoding.- Parameters:
file
- a Filereader
- the Reader supplying the text to append at the end of the Filecharset
- the charset used- Throws:
IOException
- if an IOException occurs.- Since:
- 2.3.0
-
append
@Deprecated public static void append(Path file, Reader reader, String charset, boolean writeBom) throws IOExceptionDeprecated.Append the text supplied by the Reader at the end of the File, using a specified encoding. If the given charset is "UTF-16BE" or "UTF-16LE" (or an equivalent alias),writeBom
istrue
, and the file doesn't already exist, the requisite byte order mark is written to the file before the text is appended.- Parameters:
file
- a Filereader
- the Reader supplying the text to append at the end of the Filecharset
- the charset usedwriteBom
- whether to write the BOM- Throws:
IOException
- if an IOException occurs.- Since:
- 2.5.0
-
eachFile
@Deprecated public static void eachFile(Path self, FileType fileType, Closure closure) throws IOExceptionDeprecated.Invokes 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.- Parameters:
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- Throws:
FileNotFoundException
- if the given directory does not existIllegalArgumentException
- if the provided Path object does not represent a directoryIOException
- Since:
- 2.3.0
-
eachFile
Deprecated.Invokes the closure for each 'child' file in this 'parent' folder/directory. Both regular files and subfolders/subdirectories are processed.- Parameters:
self
- a Path (that happens to be a folder/directory)closure
- a closure (the parameter is the Path for the 'child' file)- Throws:
FileNotFoundException
- if the given directory does not existIllegalArgumentException
- if the provided Path object does not represent a directoryIOException
- Since:
- 2.3.0
- See Also:
eachFile(Path, groovy.io.FileType, groovy.lang.Closure)
-
eachDir
Deprecated.Invokes the closure for each subdirectory in this directory, ignoring regular files.- Parameters:
self
- a Path (that happens to be a folder/directory)closure
- a closure (the parameter is the Path for the subdirectory file)- Throws:
FileNotFoundException
- if the given directory does not existIllegalArgumentException
- if the provided Path object does not represent a directoryIOException
- Since:
- 2.3.0
- See Also:
eachFile(Path, groovy.io.FileType, groovy.lang.Closure)
-
eachFileRecurse
@Deprecated public static void eachFileRecurse(Path self, FileType fileType, Closure closure) throws IOExceptionDeprecated.Processes each descendant file in this directory and any sub-directories. Processing consists of potentially callingclosure
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.- Parameters:
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 file- Throws:
FileNotFoundException
- if the given directory does not existIllegalArgumentException
- if the provided Path object does not represent a directoryIOException
- Since:
- 2.3.0
-
traverse
@Deprecated public static void traverse(Path self, Map<String,Object> options, Closure closure) throws IOExceptionDeprecated.Processes each descendant file in this directory and any sub-directories. Processing consists of potentially callingclosure
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:- type
- A
FileType
enum to determine if normal files or directories or both are processed - preDir
- A
Closure
run before each directory is processed and optionally returning aFileVisitResult
value which can be used to control subsequent processing. - preRoot
- A boolean indicating that the 'preDir' closure should be applied at the root level
- postDir
- A
Closure
run after each directory is processed and optionally returning aFileVisitResult
value which can be used to control subsequent processing. - postRoot
- A boolean indicating that the 'postDir' closure should be applied at the root level
- visitRoot
- A boolean indicating that the given closure should be applied for the root dir
(not applicable if the 'type' is set to
FileType.FILES
) - maxDepth
- The maximum number of directory levels when recursing (default is -1 which means infinite, set to 0 for no recursion)
- filter
- A filter to perform on traversed files/directories (using the
DefaultGroovyMethods.isCase(Object, Object)
method). If set, only files/dirs which match are candidates for visiting. - nameFilter
- A filter to perform on the name of traversed files/directories (using the
DefaultGroovyMethods.isCase(Object, Object)
method). If set, only files/dirs which match are candidates for visiting. (Must not be set if 'filter' is set) - excludeFilter
- A filter to perform on traversed files/directories (using the
DefaultGroovyMethods.isCase(Object, Object)
method). If set, any candidates which match won't be visited. - excludeNameFilter
- A filter to perform on the names of traversed files/directories (using the
DefaultGroovyMethods.isCase(Object, Object)
method). If set, any candidates which match won't be visited. (Must not be set if 'excludeFilter' is set) - sort
- A
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++ }- Parameters:
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 aFileVisitResult
value which can be used to control subsequent processing- Throws:
FileNotFoundException
- if the given directory does not existIllegalArgumentException
- if the provided Path object does not represent a directory or illegal filter combinations are suppliedIOException
- Since:
- 2.3.0
- See Also:
DefaultGroovyMethods.sort(java.lang.Iterable, groovy.lang.Closure)
,FileVisitResult
,FileType
-
traverse
Deprecated.Processes each descendant file in this directory and any sub-directories. Convenience method fortraverse(Path, java.util.Map, groovy.lang.Closure)
when no options to alter the traversal behavior are required.- Parameters:
self
- a Path (that happens to be a folder/directory)closure
- the Closure to invoke on each file/directory and optionally returning aFileVisitResult
value which can be used to control subsequent processing- Throws:
FileNotFoundException
- if the given directory does not existIllegalArgumentException
- if the provided Path object does not represent a directoryIOException
- Since:
- 2.3.0
- See Also:
traverse(Path, java.util.Map, groovy.lang.Closure)
-
traverse
Deprecated.Invokes the closure specified with key 'visit' in the options Map for each descendant file in this directory tree. Convenience method fortraverse(Path, java.util.Map, groovy.lang.Closure)
allowing the 'visit' closure to be included in the options Map rather than as a parameter.- Parameters:
self
- a Path (that happens to be a folder/directory)options
- a Map of options to alter the traversal behavior- Throws:
FileNotFoundException
- if the given directory does not existIllegalArgumentException
- if the provided Path object does not represent a directory or illegal filter combinations are suppliedIOException
- Since:
- 2.3.0
- See Also:
traverse(Path, java.util.Map, groovy.lang.Closure)
-
eachFileRecurse
Deprecated.Processes each descendant file in this directory and any sub-directories. Processing consists of callingclosure
passing it the current file (which may be a normal file or subdirectory) and then if a subdirectory was encountered, recursively processing the subdirectory.- Parameters:
self
- a Path (that happens to be a folder/directory)closure
- a Closure- Throws:
FileNotFoundException
- if the given directory does not existIllegalArgumentException
- if the provided Path object does not represent a directoryIOException
- Since:
- 2.3.0
- See Also:
eachFileRecurse(Path, groovy.io.FileType, groovy.lang.Closure)
-
eachDirRecurse
Deprecated.Recursively processes each descendant subdirectory in this directory. Processing consists of callingclosure
passing it the current subdirectory and then recursively processing that subdirectory. Regular files are ignored during traversal.- Parameters:
self
- a Path (that happens to be a folder/directory)closure
- a closure- Throws:
FileNotFoundException
- if the given directory does not existIllegalArgumentException
- if the provided Path object does not represent a directoryIOException
- Since:
- 2.3.0
- See Also:
eachFileRecurse(Path, groovy.io.FileType, groovy.lang.Closure)
-
eachFileMatch
@Deprecated public static void eachFileMatch(Path self, FileType fileType, Object nameFilter, Closure closure) throws IOExceptionDeprecated.Invokes the closure for each file whose name (file.name) matches the given nameFilter in the given directory - calling theDefaultGroovyMethods.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()}" }- Parameters:
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 theDefaultGroovyMethods.isCase(Object, Object)
method)closure
- the closure to invoke- Throws:
FileNotFoundException
- if the given directory does not existIllegalArgumentException
- if the provided Path object does not represent a directoryIOException
- Since:
- 2.3.0
-
eachFileMatch
@Deprecated public static void eachFileMatch(Path self, Object nameFilter, Closure closure) throws IOExceptionDeprecated.Invokes the closure for each file whose name (file.name) matches the given nameFilter in the given directory - calling theDefaultGroovyMethods.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.- Parameters:
self
- a Path (that happens to be a folder/directory)nameFilter
- the nameFilter to perform on the name of the file (using theDefaultGroovyMethods.isCase(Object, Object)
method)closure
- the closure to invoke- Throws:
FileNotFoundException
- if the given directory does not existIllegalArgumentException
- if the provided Path object does not represent a directoryIOException
- Since:
- 2.3.0
- See Also:
eachFileMatch(Path, groovy.io.FileType, Object, groovy.lang.Closure)
-
eachDirMatch
@Deprecated public static void eachDirMatch(Path self, Object nameFilter, Closure closure) throws IOExceptionDeprecated.Invokes the closure for each subdirectory whose name (dir.name) matches the given nameFilter in the given directory - calling theDefaultGroovyMethods.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.- Parameters:
self
- a Path (that happens to be a folder/directory)nameFilter
- the nameFilter to perform on the name of the directory (using theDefaultGroovyMethods.isCase(Object, Object)
method)closure
- the closure to invoke- Throws:
FileNotFoundException
- if the given directory does not existIllegalArgumentException
- if the provided Path object does not represent a directoryIOException
- Since:
- 2.3.0
- See Also:
eachFileMatch(Path, groovy.io.FileType, Object, groovy.lang.Closure)
-
deleteDir
Deprecated.Deletes a directory with all contained files and subdirectories.The method returns
- true, when deletion was successful
- true, when it is called for a non existing directory
- false, when it is called for a file which isn't a directory
- false, when directory couldn't be deleted
- Parameters:
self
- a Path- Returns:
- true if the file doesn't exist or deletion was successful
- Since:
- 2.3.0
-
renameTo
Deprecated.Renames a file.- Parameters:
self
- a PathnewPathName
- The new pathname for the named file- Returns:
true
if and only if the renaming succeeded;false
otherwise- Since:
- 2.3.0
-
renameTo
Deprecated.Renames a file.- Parameters:
self
- a PathnewPathName
- The new target path specified as a URI object- Returns:
true
if and only if the renaming succeeded;false
otherwise- Since:
- 2.3.0
-
asWritable
Deprecated.Converts this Path to aWritable
.- Parameters:
self
- a Path- Returns:
- a Path which wraps the input file and which implements Writable
- Since:
- 2.3.0
-
asType
Deprecated.Converts this Path to aWritable
or delegates to defaultDefaultGroovyMethods.asType(Object, Class)
.- Parameters:
path
- a Pathc
- the desired class- Returns:
- the converted object
- Since:
- 2.3.0
-
asWritable
Deprecated.Allows a file to return a Writable implementation that can output itself to a Writer stream.- Parameters:
self
- a Pathencoding
- the encoding to be used when reading the file's contents- Returns:
- Path which wraps the input file and which implements Writable
- Since:
- 2.3.0
-
newReader
Deprecated.Create a buffered reader for this file.- Parameters:
self
- a Path- Returns:
- a BufferedReader
- Throws:
IOException
- if an IOException occurs.- Since:
- 2.3.0
-
newReader
Deprecated.Create a buffered reader for this file, using the specified charset as the encoding.- Parameters:
self
- a Pathcharset
- the charset for this Path- Returns:
- a BufferedReader
- Throws:
FileNotFoundException
- if the Path was not foundUnsupportedEncodingException
- if the encoding specified is not supportedIOException
- Since:
- 2.3.0
-
withReader
Deprecated.Create a new BufferedReader for this file and then passes it into the closure, ensuring the reader is closed after the closure returns.- Parameters:
self
- a file objectclosure
- a closure- Returns:
- the value returned by the closure
- Throws:
IOException
- if an IOException occurs.- Since:
- 2.3.0
-
withReader
@Deprecated public static <T> T withReader(Path self, String charset, Closure<T> closure) throws IOExceptionDeprecated.Create a new BufferedReader for this file using the specified charset and then passes it into the closure, ensuring the reader is closed after the closure returns. The writer will use the given charset encoding, but will not write a BOM.- Parameters:
self
- a file objectcharset
- the charset for this input streamclosure
- a closure- Returns:
- the value returned by the closure
- Throws:
IOException
- if an IOException occurs.- Since:
- 2.3.0
-
newOutputStream
Deprecated.Create a buffered output stream for this file.- Parameters:
self
- a file object- Returns:
- the created OutputStream
- Throws:
IOException
- if an IOException occurs.- Since:
- 2.3.0
-
newDataOutputStream
Deprecated.Creates a new data output stream for this file.- Parameters:
self
- a file object- Returns:
- the created DataOutputStream
- Throws:
IOException
- if an IOException occurs.- Since:
- 2.3.0
-
withOutputStream
Deprecated.Creates a new OutputStream for this file and passes it into the closure. This method ensures the stream is closed after the closure returns.- Parameters:
self
- a Pathclosure
- a closure- Returns:
- the value returned by the closure
- Throws:
IOException
- if an IOException occurs.- Since:
- 2.3.0
- See Also:
IOGroovyMethods.withStream(java.io.OutputStream, groovy.lang.Closure)
-
withInputStream
Deprecated.Create a new InputStream for this file and passes it into the closure. This method ensures the stream is closed after the closure returns.- Parameters:
self
- a Pathclosure
- a closure- Returns:
- the value returned by the closure
- Throws:
IOException
- if an IOException occurs.- Since:
- 2.3.0
- See Also:
IOGroovyMethods.withStream(java.io.InputStream, groovy.lang.Closure)
-
withDataOutputStream
@Deprecated public static <T> T withDataOutputStream(Path self, Closure<T> closure) throws IOExceptionDeprecated.Create a new DataOutputStream for this file and passes it into the closure. This method ensures the stream is closed after the closure returns.- Parameters:
self
- a Pathclosure
- a closure- Returns:
- the value returned by the closure
- Throws:
IOException
- if an IOException occurs.- Since:
- 2.3.0
- See Also:
IOGroovyMethods.withStream(java.io.OutputStream, groovy.lang.Closure)
-
withDataInputStream
@Deprecated public static <T> T withDataInputStream(Path self, Closure<T> closure) throws IOExceptionDeprecated.Create a new DataInputStream for this file and passes it into the closure. This method ensures the stream is closed after the closure returns.- Parameters:
self
- a Pathclosure
- a closure- Returns:
- the value returned by the closure
- Throws:
IOException
- if an IOException occurs.- Since:
- 2.3.0
- See Also:
IOGroovyMethods.withStream(java.io.InputStream, groovy.lang.Closure)
-
newWriter
Deprecated.Create a buffered writer for this file.- Parameters:
self
- a Path- Returns:
- a BufferedWriter
- Throws:
IOException
- if an IOException occurs.- Since:
- 2.3.0
-
newWriter
Deprecated.Creates a buffered writer for this file, optionally appending to the existing file content.- Parameters:
self
- a Pathappend
- true if data should be appended to the file- Returns:
- a BufferedWriter
- Throws:
IOException
- if an IOException occurs.- Since:
- 2.3.0
-
newWriter
@Deprecated public static BufferedWriter newWriter(Path self, String charset, boolean append) throws IOExceptionDeprecated.Helper method to create a buffered writer for a file without writing a BOM.- Parameters:
self
- a Pathcharset
- the name of the encoding used to write in this fileappend
- true if in append mode- Returns:
- a BufferedWriter
- Throws:
IOException
- if an IOException occurs.- Since:
- 2.3.0
-
newWriter
@Deprecated public static BufferedWriter newWriter(Path self, String charset, boolean append, boolean writeBom) throws IOExceptionDeprecated.Helper method to create a buffered writer for a file. If the given charset is "UTF-16BE" or "UTF-16LE" (or an equivalent alias), the requisite byte order mark is written to the stream before the writer is returned.- Parameters:
self
- a Pathcharset
- the name of the encoding used to write in this fileappend
- true if in append modewriteBom
- whether to write a BOM- Returns:
- a BufferedWriter
- Throws:
IOException
- if an IOException occurs.- Since:
- 2.5.0
-
newWriter
Deprecated.Creates a buffered writer for this file without writing a BOM, writing data using the given encoding.- Parameters:
self
- a Pathcharset
- the name of the encoding used to write in this file- Returns:
- a BufferedWriter
- Throws:
IOException
- if an IOException occurs.- Since:
- 2.3.0
-
withWriter
Deprecated.Creates a new BufferedWriter for this file, passes it to the closure, and ensures the stream is flushed and closed after the closure returns. The writer will not write a BOM.- Parameters:
self
- a Pathclosure
- a closure- Returns:
- the value returned by the closure
- Throws:
IOException
- if an IOException occurs.- Since:
- 2.3.0
-
withWriter
@Deprecated public static <T> T withWriter(Path self, String charset, Closure<T> closure) throws IOExceptionDeprecated.Creates a new BufferedWriter for this file, passes it to the closure, and ensures the stream is flushed and closed after the closure returns. The writer will use the given charset encoding, but will not write a BOM.- Parameters:
self
- a Pathcharset
- the charset usedclosure
- a closure- Returns:
- the value returned by the closure
- Throws:
IOException
- if an IOException occurs.- Since:
- 2.3.0
-
withWriter
@Deprecated public static <T> T withWriter(Path self, String charset, boolean writeBom, Closure<T> closure) throws IOExceptionDeprecated.Creates a new BufferedWriter for this file, passes it to the closure, and ensures the stream is flushed and closed after the closure returns. The writer will use the given charset encoding. If the given charset is "UTF-16BE" or "UTF-16LE" (or an equivalent alias),writeBom
istrue
, and the file doesn't already exist, the requisite byte order mark is written to the stream when the writer is created.- Parameters:
self
- a Pathcharset
- the charset usedwriteBom
- whether to write the BOMclosure
- a closure- Returns:
- the value returned by the closure
- Throws:
IOException
- if an IOException occurs.- Since:
- 2.5.0
-
withWriterAppend
@Deprecated public static <T> T withWriterAppend(Path self, String charset, Closure<T> closure) throws IOExceptionDeprecated.Create a new BufferedWriter which will append to this file. The writer is passed to the closure and will be closed before this method returns. The writer will use the given charset encoding, but will not write a BOM.- Parameters:
self
- a Pathcharset
- the charset usedclosure
- a closure- Returns:
- the value returned by the closure
- Throws:
IOException
- if an IOException occurs.- Since:
- 2.3.0
-
withWriterAppend
@Deprecated public static <T> T withWriterAppend(Path self, String charset, boolean writeBom, Closure<T> closure) throws IOExceptionDeprecated.Create a new BufferedWriter which will append to this file. The writer is passed to the closure and will be closed before this method returns. The writer will use the given charset encoding. If the given charset is "UTF-16BE" or "UTF-16LE" (or an equivalent alias),writeBom
istrue
, and the file doesn't already exist, the requisite byte order mark is written to the stream when the writer is created.- Parameters:
self
- a Pathcharset
- the charset usedwriteBom
- whether to write the BOMclosure
- a closure- Returns:
- the value returned by the closure
- Throws:
IOException
- if an IOException occurs.- Since:
- 2.5.0
-
withWriterAppend
Deprecated.Create a new BufferedWriter for this file in append mode. The writer is passed to the closure and is closed after the closure returns. The writer will not write a BOM.- Parameters:
self
- a Pathclosure
- a closure- Returns:
- the value returned by the closure
- Throws:
IOException
- if an IOException occurs.- Since:
- 2.3.0
-
newPrintWriter
Deprecated.Create a new PrintWriter for this file.- Parameters:
self
- a Path- Returns:
- the created PrintWriter
- Throws:
IOException
- if an IOException occurs.- Since:
- 2.3.0
-
newPrintWriter
Deprecated.Create a new PrintWriter for this file, using specified charset.- Parameters:
self
- a Pathcharset
- the charset- Returns:
- a PrintWriter
- Throws:
IOException
- if an IOException occurs.- Since:
- 2.3.0
-
withPrintWriter
Deprecated.Create a new PrintWriter for this file which is then passed it into the given closure. This method ensures its the writer is closed after the closure returns.- Parameters:
self
- a Pathclosure
- the closure to invoke with the PrintWriter- Returns:
- the value returned by the closure
- Throws:
IOException
- if an IOException occurs.- Since:
- 2.3.0
-
withPrintWriter
@Deprecated public static <T> T withPrintWriter(Path self, String charset, Closure<T> closure) throws IOExceptionDeprecated.Create a new PrintWriter with a specified charset for this file. The writer is passed to the closure, and will be closed before this method returns.- Parameters:
self
- a Pathcharset
- the charsetclosure
- the closure to invoke with the PrintWriter- Returns:
- the value returned by the closure
- Throws:
IOException
- if an IOException occurs.- Since:
- 2.3.0
-
newInputStream
Deprecated.Creates a buffered input stream for this file.- Parameters:
self
- a Path- Returns:
- a BufferedInputStream of the file
- Throws:
FileNotFoundException
- if the file is not found.IOException
- Since:
- 2.3.0
-
newDataInputStream
Deprecated.Create a data input stream for this file- Parameters:
self
- a Path- Returns:
- a DataInputStream of the file
- Throws:
FileNotFoundException
- if the file is not found.IOException
- Since:
- 2.3.0
-
eachByte
Deprecated.Traverse through each byte of this Path- Parameters:
self
- a Pathclosure
- a closure- Throws:
IOException
- if an IOException occurs.- Since:
- 2.3.0
- See Also:
IOGroovyMethods.eachByte(java.io.InputStream, groovy.lang.Closure)
-
eachByte
@Deprecated public static void eachByte(Path self, int bufferLen, Closure closure) throws IOExceptionDeprecated.Traverse through the bytes of this Path, bufferLen bytes at a time.- Parameters:
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.- Throws:
IOException
- if an IOException occurs.- Since:
- 2.3.0
- See Also:
IOGroovyMethods.eachByte(java.io.InputStream, int, groovy.lang.Closure)
-
filterLine
Deprecated.Filters the lines of a Path and creates a Writable in return to stream the filtered lines.- Parameters:
self
- a Pathclosure
- a closure which returns a boolean indicating to filter the line or not- Returns:
- a Writable closure
- Throws:
IOException
- ifself
is not readable- Since:
- 2.3.0
- See Also:
IOGroovyMethods.filterLine(java.io.Reader, groovy.lang.Closure)
-
filterLine
@Deprecated public static Writable filterLine(Path self, String charset, Closure closure) throws IOExceptionDeprecated.Filters the lines of a Path and creates a Writable in return to stream the filtered lines.- Parameters:
self
- a Pathcharset
- opens the file with a specified charsetclosure
- a closure which returns a boolean indicating to filter the line or not- Returns:
- a Writable closure
- Throws:
IOException
- if an IOException occurs- Since:
- 2.3.0
- See Also:
IOGroovyMethods.filterLine(java.io.Reader, groovy.lang.Closure)
-
filterLine
@Deprecated public static void filterLine(Path self, Writer writer, Closure closure) throws IOExceptionDeprecated.Filter the lines from this Path, and write them to the given writer based on the given closure predicate.- Parameters:
self
- a Pathwriter
- a writer destination to write filtered lines toclosure
- a closure which takes each line as a parameter and returnstrue
if the line should be written to this writer.- Throws:
IOException
- ifself
is not readable- Since:
- 2.3.0
- See Also:
IOGroovyMethods.filterLine(java.io.Reader, java.io.Writer, groovy.lang.Closure)
-
filterLine
@Deprecated public static void filterLine(Path self, Writer writer, String charset, Closure closure) throws IOExceptionDeprecated.Filter the lines from this Path, and write them to the given writer based on the given closure predicate.- Parameters:
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 returnstrue
if the line should be written to this writer.- Throws:
IOException
- if an IO error occurs- Since:
- 2.3.0
- See Also:
IOGroovyMethods.filterLine(java.io.Reader, java.io.Writer, groovy.lang.Closure)
-
readBytes
Deprecated.Reads the content of the file into a byte array.- Parameters:
self
- a Path- Returns:
- a byte array with the contents of the file.
- Throws:
IOException
- if an IOException occurs.- Since:
- 2.3.0
-
withCloseable
@Deprecated public static <T> T withCloseable(Closeable self, Closure<T> action) throws IOExceptionDeprecated.#deprecated use the variant in IOGroovyMethods- Throws:
IOException
- Since:
- 2.3.0
- See Also:
IOGroovyMethods.withCloseable(java.io.Closeable, groovy.lang.Closure)
-