code: public static void eachByte(InputStream is, int bufferLen, @ClosureParams(value=FromString.class, options="byte[],Integer") Closure closure) throws IOException {
          byte[] buffer = new byte[bufferLen];
          int bytesRead;
          try {
              while ((bytesRead = is.read(buffer, 0, bufferLen)) > 0) {
                  closure.call(buffer, bytesRead);
              }
  
              InputStream temp = is;
              is = null;
              temp.close();
          } finally {
              closeWithWarning(is);
          }
      }
docs: 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.
  
  @param is        stream to iterate over, closed after the method call.
  @param bufferLen the length of the buffer to use.
  @param closure   a 2 parameter closure which is passed the byte[] and a number of bytes successfully read.
  @throws IOException if an IOException occurs.
  @since 1.8