code: public static String readStreamAsString(InputStream stream) throws IOException {
          try (Scanner sc = new Scanner(stream, Charset.defaultCharset().name())) {
              sc.useDelimiter("\\A");
              return sc.next();
          }
      }
docs: Reads whole content of input stream to String
  
  @param stream Opened stream
  @return Stream content
  @throws IOException Thrown if data couldn't be loaded