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.
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public static void | |
| public static void | |
| public static void | |
| public static void | |
| public static void | |
| public static void | |
| public static void | |
| public static void | |
| public static void | |
| public static void | |
| public static void | |
| public static void | |
| public static void | |
| public static void | |
| private static void | |
| private static void | |
| public static <T> T | Returns: the converted objecta File f, Class<T> the desired class c)Converts this File to a |
| public static File | Returns: a File which wraps the input file and which implements Writablea File file)Converts this File to a |
| public static File | Returns: File which wraps the input file and which implements Writablea File file, String the encoding to be used when reading the file's contents encoding)Allows a file to return a Writable implementation that can output itself to a Writer stream. |
| private static void | |
| private static InputStream | Returns: an InputStream from the underlying URLConnectionan optional map specifying part or all of supported connection parameters parameters, URL the url for which to create the inputstream url)Creates an inputstream for this URL, with the possibility to set different connection parameters using the parameters map:
|
| public static boolean | |
| public static long | Returns: directory size (length)a file object self)Calculates directory size as total size of all its files, recursively. |
| public static void | |
| public static void | |
| public static void | |
| public static void | |
| public static void | |
| public static void | eachDirMatch(final File
a File (that happens to be a folder/directory) self, final Object the nameFilter to perform on the name of the directory (using the nameFilter, final Closure<V> DefaultGroovyMethods#isCase(java. method)the closure to invoke closure)Invokes the closure for each subdirectory whose name (dir.name) matches the given nameFilter in the given directory
- calling the |
| public static void | eachDirRecurse(final File
a File (that happens to be a folder/directory) self, final Closure<V> a closure closure)Recursively processes each descendant subdirectory in this directory. |
| public static void | |
| public static void | |
| public static void | eachFileMatch(final File
a File (that happens to be a folder/directory) self, final FileType whether normal files or directories or both should be processed fileType, final Object the filter to perform on the name of the file/directory (using the nameFilter, final Closure<V> DefaultGroovyMethods#isCase(java. method)the closure to invoke closure)Invokes the closure for each file whose name (file.name) matches the given nameFilter in the given directory
- calling the |
| public static void | eachFileMatch(final File
a File (that happens to be a folder/directory) self, final Object the nameFilter to perform on the name of the file (using the nameFilter, final Closure<V> DefaultGroovyMethods#isCase(java. method)the closure to invoke closure)Invokes the closure for each file whose name (file.name) matches the given nameFilter in the given directory
- calling the |
| public static void | eachFileRecurse(final File
a File (that happens to be a folder/directory) self, final FileType if normal files or directories or both should be processed fileType, final Closure<V> the closure to invoke on each file closure)Processes each descendant file in this directory and any sub-directories. |
| public static void | eachFileRecurse(File
a File (that happens to be a folder/directory) self, Closure<V> a Closure closure)Processes each descendant file in this directory and any sub-directories. |
| public static <T> T | |
| public static <T> T | |
| public static <T> T | |
| public static <T> T | Returns: the last value returned by the closurea File self, String opens the file with a specified charset charset, int the line number value used for the first line (default is 1, set to 0 to start counting from 0) firstLine, Closure<T> a closure (arg 1 is line, optional arg 2 is line number) closure)Iterates through this file line by line. |
| public static <T> T | Returns: the last value returned by the closurea URL to open and read url, Closure<T> a closure to apply on each line (arg 1 is line, optional arg 2 is line number starting at line 1) closure)Iterates through the lines read from the URL's associated input stream passing each line to the given 1 or 2 arg closure. |
| public static <T> T | Returns: the last value returned by the closurea URL to open and read url, int the line number value used for the first line (default is 1, set to 0 to start counting from 0) firstLine, Closure<T> a closure to apply on each line (arg 1 is line, optional arg 2 is line number) closure)Iterates through the lines read from the URL's associated input stream passing each line to the given 1 or 2 arg closure. |
| public static <T> T | Returns: the last value returned by the closurea URL to open and read url, String opens the stream with a specified charset charset, Closure<T> a closure to apply on each line (arg 1 is line, optional arg 2 is line number starting at line 1) closure)Iterates through the lines read from the URL's associated input stream passing each line to the given 1 or 2 arg closure. |
| public static <T> T | Returns: the last value returned by the closurea URL to open and read url, String opens the stream with a specified charset charset, int the line number value used for the first line (default is 1, set to 0 to start counting from 0) firstLine, Closure<T> a closure to apply on each line (arg 1 is line, optional arg 2 is line number) closure)Iterates through the lines read from the URL's associated input stream passing each line to the given 1 or 2 arg closure. |
| public static void | eachObject(File
a File self, Closure<V> a closure closure)Iterates through the given file object by object. |
| public static Writable | Returns: a Writable closurea File self, Closure<V> a closure which returns a boolean indicating to filter
the line or not closure)Filters the lines of a File and creates a Writable in return to stream the filtered lines. |
| public static Writable | Returns: a Writable closurea File self, String opens the file with a specified charset charset, Closure<V> a closure which returns a boolean indicating to filter
the line or not closure)Filters the lines of a File and creates a Writable in return to stream the filtered lines. |
| public static void | filterLine(File
a File self, Writer a writer destination to write filtered lines to writer, Closure<V> a closure which takes each line as a parameter and returns
closure)true if the line should be written to this writer.Filter the lines from this File, and write them to the given writer based on the given closure predicate. |
| public static void | filterLine(File
a File self, Writer a writer destination to write filtered lines to writer, String opens the file with a specified charset charset, Closure<V> a closure which takes each line as a parameter and returns
closure)true if the line should be written to this writer.Filter the lines from this File, and write them to the given writer based on the given closure predicate. |
| public static Writable | Returns: a writable which writes out the filtered linesa URL self, Closure<V> a closure which returns boolean and takes a line predicate)Filter lines from a URL using a closure predicate. |
| public static Writable | Returns: a writable which writes out the filtered linesthe URL self, String opens the URL with a specified charset charset, Closure<V> a closure which returns boolean and takes a line predicate)Filter lines from a URL using a closure predicate. |
| public static void | filterLine(URL
the URL self, Writer a writer to write output to writer, Closure<V> a closure which returns true if a line should be accepted predicate)Uses a closure to filter lines from this URL and pass them to the given writer. |
| public static void | filterLine(URL
the URL self, Writer a writer to write output to writer, String opens the URL with a specified charset charset, Closure<V> a closure which returns true if a line should be accepted predicate)Uses a closure to filter lines from this URL and pass them to the given writer. |
| public static byte[] | |
| public static byte[] | |
| public static byte[] | |
| private static String | |
| private static String | |
| private static String[] | Returns: Strings, never nullto get names from path)Gets all names of the path as an array of |
| public static String | |
| public static String | |
| public static String | |
| public static String | |
| public static String | |
| public static String | |
| public static File | |
| public static File | |
| public static File | Returns: the filea File file, InputStream an InputStream of data to write to the file data)Append binary data to the file. |
| public static DataInputStream | Returns: a DataInputStream of the filea File file)Create a data input stream for this file |
| public static DataOutputStream | Returns: the created DataOutputStreama file object file)Creates a new data output stream for this file. |
| public static BufferedInputStream | Returns: a BufferedInputStream of the filea File file)Creates a buffered input stream for this file. |
| public static BufferedInputStream | Returns: a BufferedInputStream for the URLa URL url)Creates a buffered input stream for this URL. |
| public static BufferedInputStream | Returns: a BufferedInputStream for the URLa URL url, Map<K, V> connection parameters parameters)Creates a buffered input stream for this URL. |
| public static ObjectInputStream | Returns: an object input streama file file)Create an object input stream for this file. |
| public static ObjectInputStream | Returns: an object input streama file file, final ClassLoader the class loader to use when loading the class classLoader)Create an object input stream for this file using the given class loader. |
| public static ObjectOutputStream | Returns: an object output streama file file)Create an object output stream for this file. |
| public static BufferedOutputStream | Returns: the created OutputStreama file object file)Create a buffered output stream for this file. |
| public static PrintWriter | Returns: the created PrintWritera File file)Create a new PrintWriter for this file. |
| public static PrintWriter | Returns: a PrintWritera File file, String the charset charset)Create a new PrintWriter for this file, using specified charset. |
| public static BufferedReader | |
| public static BufferedReader | |
| public static BufferedReader | |
| public static BufferedReader | |
| public static BufferedReader | |
| public static BufferedReader | |
| public static BufferedWriter | |
| public static BufferedWriter | |
| public static BufferedWriter | |
| public static BufferedWriter | |
| public static BufferedWriter | |
| private static boolean | |
| public static byte[] | |
| public static List | |
| public static List | |
| public static List | |
| public static List | |
| public static String | Returns: the relative path between the filesthe self, File File to calculate the path fromthe to)File to calculate the path toRelative path to file. |
| public static boolean | |
| public static void | |
| public static void | |
| public static void | |
| public static long | |
| public static <T> T | Returns: the last value returned by the closurea File self, String the delimiting regular expression regex, Closure<T> a closure closure)Iterates through this file line by line, splitting each line using the given regex separator. |
| public static <T> T | Returns: the last value returned by the closurea File self, Pattern the regular expression Pattern for the delimiter pattern, Closure<T> a closure closure)Iterates through this file line by line, splitting each line using the given separator Pattern. |
| public static <T> T | Returns: the last value returned by the closurea File self, String the delimiting regular expression regex, String opens the file with a specified charset charset, Closure<T> a closure closure)Iterates through this file line by line, splitting each line using the given regex separator. |
| public static <T> T | Returns: the last value returned by the closurea File self, Pattern the regular expression Pattern for the delimiter pattern, String opens the file with a specified charset charset, Closure<T> a closure closure)Iterates through this file line by line, splitting each line using the given regex separator Pattern. |
| public static <T> T | Returns: the last value returned by the closurea URL to open and read self, String the delimiting regular expression regex, Closure<T> a closure closure)Iterates through the input stream associated with this URL line by line, splitting each line using the given regex separator. |
| public static <T> T | Returns: the last value returned by the closurea URL to open and read self, Pattern the regular expression Pattern for the delimiter pattern, Closure<T> a closure closure)Iterates through the input stream associated with this URL line by line, splitting each line using the given regex separator Pattern. |
| public static <T> T | Returns: the last value returned by the closurea URL to open and read self, String the delimiting regular expression regex, String opens the file with a specified charset charset, Closure<T> a closure closure)Iterates through the input stream associated with this URL line by line, splitting each line using the given regex separator. |
| public static <T> T | Returns: the last value returned by the closurea URL to open and read self, Pattern the regular expression Pattern for the delimiter pattern, String opens the file with a specified charset charset, Closure<T> a closure closure)Iterates through the input stream associated with this URL line by line, splitting each line using the given regex separator Pattern. |
| public static URI | Returns: a URIthe CharSequence representing a URI self)Transforms a CharSequence representing a URI into a URI object. |
| public static URI | |
| public static URL | Returns: a URLthe CharSequence representing a URL self)Transforms a CharSequence representing a URL into a URL object. |
| public static URL | |
| public static void | traverse(final File
a File (that happens to be a folder/directory) self, final Map<String, ?> a Map of options to alter the traversal behavior options, final Closure<V> the Closure to invoke on each file/directory and optionally returning a closure)groovy. value
which can be used to control subsequent processingProcesses each descendant file in this directory and any sub-directories. |
| public static void | traverse(final File
a File (that happens to be a folder/directory) self, final Closure<V> the Closure to invoke on each file/directory and optionally returning a closure)groovy. value
which can be used to control subsequent processingProcesses each descendant file in this directory and any sub-directories. |
| public static void | |
| private static FileVisitResult | |
| public static <T> T | Returns: the value returned by the closurea File file, Closure<T> a closure closure)Create a new DataInputStream for this file and passes it into the closure. |
| public static <T> T | Returns: the value returned by the closurea File file, Closure<T> a closure closure)Create a new DataOutputStream for this file and passes it into the closure. |
| public static Object | Returns: the value returned by the closurea File file, Closure<V> a closure closure)Create a new InputStream for this file and passes it into the closure. |
| public static <T> T | Returns: the value returned by the closurea URL url, Closure<T> a closure closure)Creates a new InputStream for this URL and passes it into the closure. |
| public static <T> T | Returns: the value returned by the closurea File file, Closure<T> a closure closure)Create a new ObjectInputStream for this file and pass it to the closure. |
| public static <T> T | Returns: the value returned by the closurea File file, ClassLoader the class loader to use when loading the class classLoader, Closure<T> a closure closure)Create a new ObjectInputStream for this file associated with the given class loader and pass it to the closure. |
| public static <T> T | Returns: the value returned by the closurea File file, Closure<T> a closure closure)Create a new ObjectOutputStream for this file and then pass it to the closure. |
| public static Object | Returns: the value returned by the closurea File file, Closure<V> a closure closure)Creates a new OutputStream for this file and passes it into the closure. |
| public static <T> T | Returns: the value returned by the closurea File file, Closure<T> the closure to invoke with the PrintWriter closure)Create a new PrintWriter for this file which is then passed it into the given closure. |
| public static <T> T | Returns: the value returned by the closurea File file, String the charset charset, Closure<T> the closure to invoke with the PrintWriter closure)Create a new PrintWriter with a specified charset for this file. |
| public static <T> T | Returns: the value returned by the closurea file object file, Closure<T> a closure closure)Create a new BufferedReader for this file and then passes it into the closure, ensuring the reader is closed after the closure returns. |
| public static <T> T | Returns: the value returned by the closurea file object file, String the charset for this input stream charset, Closure<T> a closure closure)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. |
| public static <T> T | Returns: the value returned by the closurea URL url, Closure<T> the closure to invoke with the reader closure)Helper method to create a new BufferedReader for a URL and then passes it to the closure. |
| public static <T> T | Returns: the value returned by the closurea URL url, String the charset used charset, Closure<T> the closure to invoke with the reader closure)Helper method to create a new Reader for a URL and then passes it to the closure. |
| public static <T> T | Returns: the value returned by the closurea File file, Closure<T> a 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. |
| public static <T> T | Returns: the value returned by the closurea File file, String the charset used charset, Closure<T> a 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. |
| public static <T> T | Returns: the value returned by the closurea File file, String the charset used charset, Closure<T> a closure closure)Create a new BufferedWriter which will append to this file. |
| public static <T> T | Returns: the value returned by the closurea File file, Closure<T> a closure closure)Create a new BufferedWriter for this file in append mode. |
| public static void | |
| public static void | |
| public static void | |
| public static void |