Groovy JDK

## java.io
Class InputStream

Method Summary
`void` | `eachByte(Closure closure)` Traverse through each byte of the specified stream stream is closed after the closure returns
`Object` | `eachLine(String charset, Closure closure)` Iterates through this stream reading with the provided charset, passing each line to the closure stream is closed after the closure returns
`Object` | `eachLine(Closure closure)` Iterates through this stream, passing each line to the closure stream is closed after the closure returns
`Writable` | `filterLine(Closure predicate)` Filter lines from an input stream using a closure predicate will be passed each line as a String, and it should return `true` if the line should be passed to the writer
`void` | `filterLine(Writer writer, Closure predicate)` Uses a closure to filter lines from this InputStream and pass them to the given writer it should return `true` if the line should be passed to the writer
`String` | `getText()` Read the content of this InputStream and return it as a String The stream is closed before this method returns
`String` | `getText(String charset)` Read the content of this InputStream using specified charset and return it as a String
`Iterator` | `iterator()` Standard iterator for a input stream which iterates through the stream content in a byte-based fashion
`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
`String` | `readLine()` Just throws a DeprecationException
`List` | `readLines()` Reads the stream into a list, with one element for each line
`Object` | `splitEachLine(String sep, String charset, Closure closure)` Iterates through the given InputStream line by line using the specified encoding, splitting each line using the given separator for each line is then passed to the given closure
`Object` | `splitEachLine(String sep, Closure closure)` Iterates through the given InputStream line by line, splitting each line using the given separator the given closure
`Object` | `withReader(Closure closure)` Helper method to create a new BufferedReader for a stream and then passes it into the closure
`Object` | `withReader(String charset, Closure closure)` Helper method to create a new BufferedReader for a stream and then passes it into the closure
`Object` | `withStream(Closure closure)` Allows this input stream to be used within the closure, ensuring that it is flushed and closed before this method returns

Method Detail

### eachByte

    public void eachByte(Closure closure)

  Traverse through each byte of the specified stream. The stream is closed after the closure returns.

Parameters:
  `closure` - closure to apply to each byte.

### eachLine

    public Object eachLine(String charset, Closure closure)

  Iterates through this stream reading with the provided charset, passing each line to the closure. The stream is closed after the closure returns.

Parameters:
  `charset` - opens the stream with a specified charset.
  `closure` - a closure.
Returns:
  the last value returned by the closure

See:
  #eachLine(Reader,Closure).

### eachLine

    public Object eachLine(Closure closure)

  Iterates through this stream, passing each line to the closure. The stream is closed after the closure returns.

Parameters:
  `closure` - a closure.
Returns:
  the last value returned by the closure

See:
  #eachLine(Reader,Closure).

### filterLine

    public Writable filterLine(Closure predicate)

  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.

Parameters:
  `predicate` - a closure which returns boolean and takes a line.
Returns:
  a writable which writes out the filtered lines

See:
  #filterLine(Reader, Closure).

### filterLine

    public void filterLine(Writer writer, Closure predicate)

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

Parameters:
  `writer` - a writer to write output to.
  `predicate` - a closure which returns true if a line should be accepted.
See:
  #filterLine(Reader,Writer,Closure).

### getText

    public String getText()

  Read the content of this InputStream and return it as a String. The stream is closed before this method returns.

Returns:
  the text from that URL

### getText

    public String getText(String charset)

  Read the content of this InputStream using specified charset and return it as a String. The stream is closed before this method returns.

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

### iterator

    public 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 BufferedReader newReader()

  Creates a reader for this input stream.

Returns:
  a reader

### newReader

    public BufferedReader newReader(String charset)

  Creates a reader for this input stream, using the specified charset as the encoding.

Parameters:
  `charset` - the charset for this input stream.
Returns:
  a reader

### readLine

    public String readLine()

  Just throws a DeprecationException. DO NOT USE. It used to read a single, whole line from the given InputStream.

Returns:
  a line

### readLines

    public List readLines()

  Reads the stream into a list, with one element for each line.

Returns:
  a List of lines

See:
  #readLines(Reader).

### splitEachLine

    public Object splitEachLine(String sep, String charset, Closure closure)

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

Parameters:
  `sep` - a String separator.
  `charset` - opens the stream with a specified charset.
  `closure` - a closure.
Returns:
  the last value returned by the closure

See:
  #splitEachLine(Reader,String,Closure).

### splitEachLine

    public Object splitEachLine(String sep, Closure closure)

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

Parameters:
  `sep` - a String separator.
  `closure` - a closure.
Returns:
  the last value returned by the closure

See:
  #splitEachLine(Reader,String,Closure).

### withReader

    public Object withReader(Closure closure)

  Helper method to create a new BufferedReader for a stream and then passes it into the closure. The reader is closed after the closure returns.

Parameters:
  `closure` - the closure to invoke with the InputStream.
Returns:
  the value returned by the closure

### withReader

    public Object withReader(String charset, Closure closure)

  Helper method to create a new BufferedReader for a stream and then passes it into the closure. The reader is closed after the closure returns.

Parameters:
  `charset` - the charset used.
  `closure` - the closure to invoke with the InputStream.
Returns:
  the value returned by the closure

### withStream

    public Object withStream(Closure closure)

  Allows this input stream to be used within the closure, ensuring that it is flushed and closed before this method returns.

Parameters:
  `closure` - the closure that the stream is passed into.
Returns:
  the value returned by the closure

Groovy JDK