Method Summary | |
---|---|
void
|
eachByte(groovy.lang.Closure closure)
Traverse through each byte of the specified stream |
void
|
eachLine(groovy.lang.Closure closure)
Iterates through the given stream line by line |
groovy.lang.Writable
|
filterLine(groovy.lang.Closure predicate)
Filter lines from an input stream using a closure predicate |
void
|
filterLine(java.io.Writer writer, groovy.lang.Closure predicate)
Filters lines from an input stream, writing to a writer, using a closure which returns boolean and takes a line |
java.lang.String
|
getText()
Reads the content of this InputStream and returns it as a String |
java.lang.String
|
getText(java.lang.String charset)
Reads the content of this InputStream with a specified charset and returns it as a String |
java.util.Iterator
|
iterator()
Standard iterator for a input stream which iterates through the stream content in a byte-based fashion |
java.io.BufferedReader
|
newReader()
Provides a reader for an arbitrary input stream |
java.lang.String
|
readLine()
Read a single, whole line from the given InputStream |
java.util.List
|
readLines()
Reads the stream into a list of Strings for each line |
void
|
withReader(groovy.lang.Closure closure)
Helper method to create a new BufferedReader for a stream and then passes it into the closure and ensures its closed again afterwords |
void
|
withStream(groovy.lang.Closure closure)
Allows a InputStream to be used, calling the closure with the stream and then ensuring that the stream is closed down again irrespective of whether exceptions occur or the |
Method Detail |
---|
public void eachByte(groovy.lang.Closure closure)
closure
- closure to apply to each byte.
public void eachLine(groovy.lang.Closure closure)
closure
- a closure.
public groovy.lang.Writable filterLine(groovy.lang.Closure predicate)
predicate
- a closure which returns boolean and takes a line.
public void filterLine(java.io.Writer writer, groovy.lang.Closure predicate)
writer
- a writer to write output to.
predicate
- a closure which returns a boolean and takes a line as input.
public java.lang.String getText()
public java.lang.String getText(java.lang.String charset)
charset
- opens the stream with a specified charset.
public java.util.Iterator iterator()
public java.io.BufferedReader newReader()
public java.lang.String readLine()
public java.util.List readLines()
public void withReader(groovy.lang.Closure closure)
closure
- the closure to invoke with the InputStream.
public void withStream(groovy.lang.Closure closure)
closure
- the closure that the stream is passed into.