code: public static String collectAndCloseStream(InputStream is) throws IOException {
          if (is != null) {
              try {
                  return IOUtils.toString(is, "UTF-8");
              } finally {
                  close(is);
              }
          } else {
              return null;
          }
      }
docs: Collects the string content of a stream (UTF8) and then closes it.
  
  @param is - an input stream to consume and close, may be {@code null}
  @return UTF-8 string content of the stream or null if there was no stream
  @throws IOException if there was a problem reading the stream