code: public static String slurpStream(InputStream input, String encoding) throws IOException {
          try (Reader r = new InputStreamReader(input, encoding)) {
              StringBuilder result = new StringBuilder();
              char[] buffer = new char[BUFFER_SIZE];
              int len = 0;
              while ((len = r.read(buffer, 0, BUFFER_SIZE)) >= 0) {
                  result.append(buffer, 0, len);
              }
              return result.toString();
          }
      }
docs: Given an input stream, its data will be slurped in memory and returned as a String. The input stream will be
  closed when this method returns. WARNING: do not slurp large streams to avoid out-of-memory errors.
  
  @param input the input stream to slup
  @param encoding the encoding to use when reading from {@code input}
  @return the input stream data as a String
  @throws IOException in IO problems