public static long size(File self)
provides a size() method for File.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.
| Modifier and Type | Field and Description |
|---|---|
| private static int | |
| private static final int | |
| private static int | |
| private static int | |
| private static final Logger |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| private static void | |
| public static void | eachByte(InputStream
stream to iterate over, closed after the method call is, Closure<V> closure to apply to each byte closure)Traverse through each byte of the specified stream. |
| public static void | eachByte(InputStream
stream to iterate over, closed after the method call. is, int the length of the buffer to use. bufferLen, Closure<V> a 2 parameter closure which is passed the byte[] and a number of bytes successfully read. closure)Traverse through each the specified stream reading bytes into a buffer and calling the 2 parameter closure with this buffer and the number of bytes. |
| public static <T> T | Returns: the last value returned by the closurea stream stream, String opens the stream with a specified charset charset, Closure<T> a closure (arg 1 is line, optional arg 2 is line number starting at line 1) closure)Iterates through this stream reading with the provided charset, passing each line to the given 1 or 2 arg closure. |
| public static <T> T | Returns: the last value returned by the closurea stream stream, 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 (arg 1 is line, optional arg 2 is line number) closure)Iterates through this stream reading with the provided charset, passing each line to the given 1 or 2 arg closure. |
| public static <T> T | Returns: the last value returned by the closurea stream stream, Closure<T> a closure (arg 1 is line, optional arg 2 is line number starting at line 1) closure)Iterates through this stream, passing each line to the given 1 or 2 arg closure. |
| public static <T> T | Returns: the last value returned by the closurea stream stream, 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 stream, passing each line to the given 1 or 2 arg closure. |
| public static <T> T | |
| public static <T> T | Returns: the last value returned by the closurea Reader, closed after the method returns self, 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 which will be passed each line (or for 2 arg closures the line and line count) closure)Iterates through the given reader line by line. |
| public static void | eachObject(ObjectInputStream
an ObjectInputStream, closed after the operation ois, Closure<V> a closure closure)Iterates through the given object stream object by object. |
| public static void | filterLine(Reader
a reader, closed after the call reader, Writer a writer, closed after the call writer, Closure<V> the closure which returns booleans closure)Filter the lines from a reader and write them on the writer, according to a closure which returns true if the line should be included. |
| public static Writable | Returns: a Writable which will use the closure to filter each line from the reader when the Writable#writeTo(Writer) is called.this reader reader, final Closure<V> a closure used for filtering closure)Filter the lines from this Reader, and return a Writable which can be used to stream the filtered lines to a destination. |
| public static Writable | Returns: a writable which writes out the filtered linesan input stream self, Closure<V> a closure which returns boolean and takes a line predicate)Filter lines from an input stream using a closure predicate. |
| public static Writable | Returns: a writable which writes out the filtered linesan input stream self, String opens the stream with a specified charset charset, Closure<V> a closure which returns boolean and takes a line predicate)Filter lines from an input stream using a closure predicate. |
| public static void | filterLine(InputStream
the InputStream 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 InputStream and pass them to the given writer. |
| public static void | filterLine(InputStream
the InputStream self, Writer a writer to write output to writer, String opens the stream 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 InputStream and pass them to the given writer. |
| public static byte[] | Returns: the byte[] from that InputStreaman input stream is)Read the content of this InputStream and return it as a byte[]. |
| public static String | Returns: the text from that URLan input stream is)Read the content of this InputStream and return it as a String. |
| public static String | Returns: the text from that URLan input stream is, String opens the stream with a specified charset charset)Read the content of this InputStream using specified charset and return it as a String. |
| public static String | |
| public static String | Returns: a String containing the content of the buffered readera BufferedReader whose content we want to read reader)Read the content of the BufferedReader and return it as a String. |
| private static boolean | |
| public static Iterator | |
| public static Iterator | Returns: an Iterator for the InputStreaman InputStream object self)Standard iterator for a input stream which iterates through the stream content in a byte-based fashion. |
| public static Iterator | Returns: an Iterator for the DataInputStreama DataInputStream object self)Standard iterator for a data input stream which iterates through the stream content a Byte at a time. |
| public static Writer | |
| public static Appendable | Returns: the Appendable on which this operation was invokedan Appendable self, Object an Object whose default representation will be appended to the Appendable value)Overloads the leftShift operator for Appendable to allow an object to be appended using Groovy's default representation for the object. |
| public static Writer | Returns: a Writeran OutputStream self, Object a value to append value)Overloads the leftShift operator to provide an append mechanism to add values to a stream. |
| public static void | leftShift(ObjectOutputStream
an ObjectOutputStream self, Object an object to write to the stream value)Overloads the leftShift operator to add objects to an ObjectOutputStream. |
| public static OutputStream | Returns: the outputstream itselfstream on which to write self, InputStream stream to read from in)Pipe an InputStream into an OutputStream for efficient stream copying. |
| public static OutputStream | Returns: an OutputStreaman OutputStream self, byte[] a value to append value)Overloads the leftShift operator to provide an append mechanism to add bytes to a stream. |
| private static int | |
| public static ObjectInputStream | Returns: an object input streaman input stream inputStream)Create an object input stream for this input stream. |
| public static ObjectInputStream | Returns: an object input streaman input stream inputStream, final ClassLoader the class loader to use when loading the class classLoader)Create an object input stream for this input stream using the given class loader. |
| public static ObjectOutputStream | Returns: an object output streaman output stream outputStream)Create an object output stream for this output stream. |
| public static PrintWriter | Returns: a PrintWritera Writer writer)Create a new PrintWriter for this Writer. |
| public static PrintWriter | Returns: a PrintWriteran OutputStream stream)Create a new PrintWriter for this OutputStream. |
| public static BufferedReader | |
| public static BufferedReader | Returns: a readeran input stream self, String the charset for this input stream charset)Creates a reader for this input stream, using the specified charset as the encoding. |
| public static Writer | Returns: the newly created Writerthe stream which is used and then closed stream)Creates a writer for this stream. |
| public static Writer | Returns: the newly created Writerthe stream which is used and then closed stream, String the charset used charset)Creates a writer for this stream using the given charset. |
| public static String | |
| private static String | |
| private static String | |
| public static List | Returns: a List of linesa stream stream)Reads the stream into a list, with one element for each line. |
| public static List | Returns: a List of linesa stream stream, String opens the stream with a specified charset charset)Reads the stream into a list, with one element for each line. |
| public static List | |
| public static void | setBytes(OutputStream
an output stream os, byte[] the byte[] to write to the output stream bytes)Write the byte[] to the output stream. |
| public static <T> T | Returns: the last value returned by the closurea Reader, closed after the method returns self, String the delimiting regular expression regex, Closure<T> a closure closure)Iterates through the given reader line by line, splitting each line using the given regex separator. |
| public static <T> T | Returns: the last value returned by the closurea Reader, closed after the method returns self, Pattern the regular expression Pattern for the delimiter pattern, Closure<T> a closure closure)Iterates through the given reader line by line, splitting each line using the given regex separator Pattern. |
| public static <T> T | Returns: the last value returned by the closurean InputStream stream, String the delimiting regular expression regex, String opens the stream with a specified charset charset, Closure<T> a closure closure)Iterates through the given InputStream line by line using the specified encoding, splitting each line using the given separator. |
| public static <T> T | Returns: the last value returned by the closurean InputStream stream, Pattern the regular expression Pattern for the delimiter pattern, String opens the stream with a specified charset charset, Closure<T> a closure closure)Iterates through the given InputStream line by line using the specified encoding, splitting each line using the given separator Pattern. |
| public static <T> T | Returns: the last value returned by the closurean InputStream stream, String the delimiting regular expression regex, Closure<T> a closure closure)Iterates through the given InputStream line by line, splitting each line using the given separator. |
| public static <T> T | Returns: the last value returned by the closurean InputStream stream, Pattern the regular expression Pattern for the delimiter pattern, Closure<T> a closure closure)Iterates through the given InputStream line by line, splitting each line using the given separator Pattern. |
| public static void | transformChar(Reader
a Reader object self, Writer a Writer to receive the transformed characters writer, Closure<V> a closure that performs the required transformation closure)Transforms each character from this reader by passing it to the given closure. |
| public static void | transformLine(Reader
Lines of text to be transformed. Reader is closed afterwards. reader, Writer Where transformed lines are written. Writer is closed afterwards. writer, Closure<V> Single parameter closure that is called to transform each line of
text from the reader, before writing it to the writer. closure)Transforms the lines from a reader with a Closure and write them to a writer. |
| public static <T, U extends Closeable> T | Returns: the value returned by the closurethe Closeable self, Closure<T> the closure taking the Closeable as parameter action)Allows this closeable to be used within the closure, ensuring that it is closed once the closure has been executed and before this method returns. |
| public static <T, U extends AutoCloseable> T | Returns: the value returned by the closurethe AutoCloseable self, Closure<T> the closure taking the AutoCloseable as parameter action)Allows this AutoCloseable to be used within the closure, ensuring that it is closed once the closure has been executed and before this method returns. |
| public static Appendable | Returns: the Appendable on which this operation was invokedan Appendable self, Closure<V> a 1-arg Closure which will be called with a Formatter as its argument closure)Invokes a Closure that uses a Formatter taking care of resource handling. |
| public static Appendable | Returns: the Appendable on which this operation was invokedan Appendable self, Locale a Locale used when creating the Formatter locale, Closure<V> a 1-arg Closure which will be called with a Formatter as its argument closure)Invokes a Closure that uses a Formatter taking care of resource handling. |
| public static <T> T | Returns: the value returned by the closurean input stream inputStream, 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 closurean input stream inputStream, ClassLoader the class loader to use when loading the class classLoader, 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 closuream output stream outputStream, Closure<T> a closure closure)Create a new ObjectOutputStream for this output stream and then pass it to the closure. |
| public static <T> T | Returns: the value returned by the closurea writer writer, Closure<T> the closure to invoke with the PrintWriter closure)Create a new PrintWriter for this Writer. |
| public static <T> T | Returns: the value returned by the closurean OutputStream stream, Closure<T> the closure to invoke with the PrintWriter closure)Create a new PrintWriter for this OutputStream. |
| public static <T> T | Returns: the value returned by the closurethe reader which is used and then closed reader, Closure<T> the closure that the writer is passed into closure)Allows this reader to be used within the closure, ensuring that it is closed before this method returns. |
| public static <T> T | Returns: the value returned by the closurea stream in, Closure<T> the closure to invoke with the InputStream closure)Helper method to create a new Reader for a stream and then passes it into the closure. |
| public static <T> T | Returns: the value returned by the closurea stream in, String the charset used to decode the stream charset, Closure<T> the closure to invoke with the reader closure)Helper method to create a new Reader for a stream and then passes it into the closure. |
| public static <T, U extends InputStream> T | Returns: the value returned by the closurethe stream which is used and then closed stream, Closure<T> the closure that the stream is passed into closure)Allows this input stream to be used within the closure, ensuring that it is flushed and closed before this method returns. |
| public static <T, U extends OutputStream> T | Returns: the value returned by the closurethe stream which is used and then closed os, Closure<T> the closure that the stream is passed into closure)Passes this OutputStream to the closure, ensuring that the stream is closed after the closure returns, regardless of errors. |
| public static <T> T | Returns: the value returned by the closurethe writer which is used and then closed writer, Closure<T> the closure that the writer is passed into closure)Allows this writer to be used within the closure, ensuring that it is flushed and closed before this method returns. |
| public static <T> T | Returns: the value returned by the closurethe stream which is used and then closed stream, Closure<T> the closure that the writer is passed into closure)Creates a writer from this stream, passing it to the given closure. |
| public static <T> T | Returns: the value returned by the closurethe stream which is used and then closed stream, String the charset used charset, Closure<T> the closure that the writer is passed into closure)Creates a writer from this stream, passing it to the given closure. |
| public static void | |
| public static void | writeLine(BufferedWriter
a BufferedWriter writer, String the line to write line)Write the text and append a newline (using the platform's line-ending). |