code: public static void process(InputStream inputStream, StreamHandler handler, byte[] buffer) throws IOException {
      LOGGER.trace("process(InputStream, StreamHandler, byte[])");
      LOGGER.debug("buffer size: {} bytes", buffer != null ? buffer.length : "null");
      int read = -1;
      while( (read = inputStream.read(buffer)) != -1 ) {
        LOGGER.debug("{} bytes read from stream", read);
        handler.handleStreamBuffer(buffer, 0, read);
      }
    }
docs: generic processing of a stream with a custom buffer
  
  @param inputStream
  the input stream to process
  @param handler
  the handler to apply on the stream
  @param buffer
  the buffer to use for stream handling
  @throws IOException