java.io
Class InputStream

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

eachByte

public void eachByte(groovy.lang.Closure closure)
Traverse through each byte of the specified stream. The stream is closed afterwards.

Parameters:
closure - closure to apply to each byte.

eachLine

public void eachLine(groovy.lang.Closure closure)
Iterates through the given stream line by line

Parameters:
closure - a closure.

filterLine

public groovy.lang.Writable filterLine(groovy.lang.Closure predicate)
Filter lines from an input stream using a closure predicate

Parameters:
predicate - a closure which returns boolean and takes a line.
Returns:
a filtered writer

filterLine

public 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.

Parameters:
writer - a writer to write output to.
predicate - a closure which returns a boolean and takes a line as input.

getText

public java.lang.String getText()
Reads the content of this InputStream and returns it as a String

Returns:
the text from that URL

getText

public java.lang.String getText(java.lang.String charset)
Reads the content of this InputStream with a specified charset and returns it as a String

Parameters:
charset - opens the stream with a specified charset.
Returns:
the text from that URL

iterator

public java.util.Iterator iterator()
Standard iterator for a input stream which iterates through the stream content in a byte-based fashion.

Returns:
an Iterator for the InputStream

newReader

public java.io.BufferedReader newReader()
Provides a reader for an arbitrary input stream

Returns:
a reader

readLine

public java.lang.String readLine()
Read a single, whole line from the given InputStream

Returns:
a line

readLines

public java.util.List readLines()
Reads the stream into a list of Strings for each line

Returns:
a List of lines

withReader

public 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.

Parameters:
closure - the closure to invoke with the InputStream.

withStream

public 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

Parameters:
closure - the closure that the stream is passed into.