public static <T,U extends InputStream>T withStream(U stream,@ClosureParams(value=FirstParam.class) Closure<T> closure) throws IOException {
  try {
    T result=closure.call(stream);
    InputStream temp=stream;
    stream=null;
    temp.close();
    return result;
  }
  finally {
    closeWithWarning(stream);
  }
}

public static < T , U extends InputStream > T withStream ( U stream , @ ClosureParams ( value = FirstParam . class ) Closure < T > closure ) throws IOException { try { T result = closure . call ( stream ) ; InputStream temp = stream ; stream = null ; temp . close ( ) ; return result ; } finally { closeWithWarning ( stream ) ; } }
allows this input stream to be used within the closure , ensuring that it is flushed and closed before this method returns .
