Return type | Name and parameters |
---|---|
void
|
eachByte(Closure closure)
Traverse through each byte of the specified stream. |
void
|
eachByte(int bufferLen, Closure 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. |
Object
|
eachLine(Closure closure)
Iterates through this stream, passing each line to the given 1 or 2 arg closure. |
Object
|
eachLine(int firstLine, Closure closure)
Iterates through this stream, passing each line to the given 1 or 2 arg closure. |
Object
|
eachLine(String charset, Closure closure)
Iterates through this stream reading with the provided charset, passing each line to the given 1 or 2 arg closure. |
Object
|
eachLine(String charset, int firstLine, Closure closure)
Iterates through this stream reading with the provided charset, passing each line to the given 1 or 2 arg closure. |
Writable
|
filterLine(Closure predicate)
Filter lines from an input stream using a closure predicate. |
void
|
filterLine(Writer writer, Closure predicate)
Uses a closure to filter lines from this InputStream and pass them to the given writer. |
void
|
filterLine(Writer writer, String charset, Closure predicate)
Uses a closure to filter lines from this InputStream and pass them to the given writer. |
Writable
|
filterLine(String charset, Closure predicate)
Filter lines from an input stream using a closure predicate. |
byte[]
|
getBytes()
Read the content of this InputStream and return it as a byte[]. |
String
|
getText()
Read the content of this InputStream and return it as a String. |
String
|
getText(String charset)
Read the content of this InputStream using specified charset and return it as a String. |
Iterator
|
iterator()
Standard iterator for an input stream which iterates through the stream content in a byte-based fashion. |
ObjectInputStream
|
newObjectInputStream()
Create an object input stream for this input stream. |
ObjectInputStream
|
newObjectInputStream(ClassLoader classLoader)
Create an object input stream for this input stream using the given class loader. |
BufferedReader
|
newReader()
Creates a reader for this input stream. |
BufferedReader
|
newReader(String charset)
Creates a reader for this input stream, using the specified charset as the encoding. |
List
|
readLines()
Reads the stream into a list, with one element for each line. |
List
|
readLines(String charset)
Reads the stream into a list, with one element for each line. |
Object
|
splitEachLine(String regex, Closure closure)
Iterates through the given InputStream line by line, splitting each line using the given separator. |
Object
|
splitEachLine(String regex, String charset, Closure closure)
Iterates through the given InputStream line by line using the specified encoding, splitting each line using the given separator. |
Object
|
splitEachLine(Pattern pattern, Closure closure)
Iterates through the given InputStream line by line, splitting each line using the given separator Pattern. |
Object
|
splitEachLine(Pattern pattern, String charset, Closure closure)
Iterates through the given InputStream line by line using the specified encoding, splitting each line using the given separator Pattern. |
Object
|
withObjectInputStream(Closure closure)
Create a new ObjectInputStream for this input stream and pass it to the closure. |
Object
|
withObjectInputStream(ClassLoader classLoader, Closure closure)
Create a new ObjectInputStream for this input stream and pass it to the closure. |
Object
|
withReader(Closure closure)
Helper method to create a new Reader for a stream and then passes it into the closure. |
Object
|
withReader(String charset, Closure closure)
Helper method to create a new Reader for a stream and then passes it into the closure. |
addShutdownHook
, any
, any
, asBoolean
, asType
, collect
, collect
, collect
, dump
, each
, eachMatch
, eachMatch
, eachWithIndex
, every
, every
, find
, find
, findAll
, findAll
, findIndexOf
, findIndexOf
, findIndexValues
, findIndexValues
, findLastIndexOf
, findLastIndexOf
, findResult
, findResult
, findResult
, findResult
, getAt
, getMetaClass
, getMetaPropertyValues
, getProperties
, grep
, grep
, hasProperty
, identity
, inject
, inject
, inspect
, invokeMethod
, is
, isCase
, isNotCase
, iterator
, metaClass
, print
, print
, printf
, printf
, println
, println
, println
, putAt
, respondsTo
, respondsTo
, setMetaClass
, split
, sprintf
, sprintf
, stream
, tap
, toString
, use
, use
, use
, with
, with
, withCloseable
, withStream
, withTraits
Traverse through each byte of the specified stream. The stream is closed after the closure returns.
closure
- closure to apply to each byteTraverse through each the specified stream reading bytes into a buffer and calling the 2 parameter closure with this buffer and the number of bytes.
bufferLen
- the length of the buffer to use.closure
- a 2 parameter closure which is passed the byte[] and a number of bytes successfully read.Iterates through this stream, passing each line to the given 1 or 2 arg closure. The stream is closed before this method returns.
closure
- a closure (arg 1 is line, optional arg 2 is line number starting at line 1)Iterates through this stream, passing each line to the given 1 or 2 arg closure. The stream is closed before this method returns.
firstLine
- the line number value used for the first line (default is 1, set to 0 to start counting from 0)closure
- a closure (arg 1 is line, optional arg 2 is line number)Iterates through this stream reading with the provided charset, passing each line to the given 1 or 2 arg closure. The stream is closed before this method returns.
charset
- opens the stream with a specified charsetclosure
- a closure (arg 1 is line, optional arg 2 is line number starting at line 1)Iterates through this stream reading with the provided charset, passing each line to the given 1 or 2 arg closure. The stream is closed after this method returns.
charset
- opens the stream with a specified charsetfirstLine
- the line number value used for the first line (default is 1, set to 0 to start counting from 0)closure
- a closure (arg 1 is line, optional arg 2 is line number)Filter lines from an input stream using a closure predicate. The closure
will be passed each line as a String, and it should return
true
if the line should be passed to the writer.
predicate
- a closure which returns boolean and takes a lineUses a closure to filter lines from this InputStream and pass them to
the given writer. The closure will be passed each line as a String, and
it should return true
if the line should be passed to the
writer.
writer
- a writer to write output topredicate
- a closure which returns true if a line should be acceptedUses a closure to filter lines from this InputStream and pass them to
the given writer. The closure will be passed each line as a String, and
it should return true
if the line should be passed to the
writer.
writer
- a writer to write output tocharset
- opens the stream with a specified charsetpredicate
- a closure which returns true if a line should be acceptedFilter lines from an input stream using a closure predicate. The closure
will be passed each line as a String, and it should return
true
if the line should be passed to the writer.
charset
- opens the stream with a specified charsetpredicate
- a closure which returns boolean and takes a lineRead the content of this InputStream and return it as a byte[]. The stream is closed before this method returns.
Read the content of this InputStream and return it as a String. The stream is closed before this method returns.
Read the content of this InputStream using specified charset and return it as a String. The stream is closed before this method returns.
charset
- opens the stream with a specified charsetStandard iterator for an input stream which iterates through the stream content in a byte-based fashion.
Create an object input stream for this input stream.
Create an object input stream for this input stream using the given class loader.
classLoader
- the class loader to use when loading the classCreates a reader for this input stream.
Creates a reader for this input stream, using the specified charset as the encoding.
charset
- the charset for this input streamReads the stream into a list, with one element for each line.
Reads the stream into a list, with one element for each line.
charset
- opens the stream with a specified charsetIterates through the given InputStream line by line, splitting each line using the given separator. The list of tokens for each line is then passed to the given closure. The stream is closed before the method returns.
regex
- the delimiting regular expressionclosure
- a closureIterates through the given InputStream line by line using the specified encoding, splitting each line using the given separator. The list of tokens for each line is then passed to the given closure. Finally, the stream is closed.
regex
- the delimiting regular expressioncharset
- opens the stream with a specified charsetclosure
- a closureIterates through the given InputStream line by line, splitting each line using the given separator Pattern. The list of tokens for each line is then passed to the given closure. The stream is closed before the method returns.
pattern
- the regular expression Pattern for the delimiterclosure
- a closureIterates through the given InputStream line by line using the specified encoding, splitting each line using the given separator Pattern. The list of tokens for each line is then passed to the given closure. Finally, the stream is closed.
pattern
- the regular expression Pattern for the delimitercharset
- opens the stream with a specified charsetclosure
- a closureCreate a new ObjectInputStream for this input stream and pass it to the closure. This method ensures the stream is closed after the closure returns.
closure
- a closureCreate a new ObjectInputStream for this input stream and pass it to the closure. This method ensures the stream is closed after the closure returns.
classLoader
- the class loader to use when loading the classclosure
- a closureHelper method to create a new Reader for a stream and then passes it into the closure. The reader (and this stream) is closed after the closure returns.
closure
- the closure to invoke with the InputStreamHelper method to create a new Reader for a stream and then passes it into the closure. The reader (and this stream) is closed after the closure returns.
charset
- the charset used to decode the streamclosure
- the closure to invoke with the reader