code: public static String read(InputStream in, String charset) throws IOException {
          if (in == null) {
              throw new IllegalArgumentException("input stream cannot be null");
          }
          InputStreamReader reader = null;
          try {
              reader = new InputStreamReader(in, charset);
              char[] buffer = new char[1024];
              StringBuilder sb = new StringBuilder();
              int len;
              while ((len = reader.read(buffer)) != -1) {
                  sb.append(buffer, 0, len);
              }
              return sb.toString();
          } finally {
              closeQuietly(reader);
          }
      }
docs: Reads contents of the input stream fully and returns it as String.
  
  @param in InputStream to read from.
  @param charset name of supported charset to use
  @return contents of the input stream fully as String.
  @throws IOException in case of IO error