code: public static String convertInputStreamToString(InputStream is, String charset) throws IOException
    {
      if (is == null)
      {
        return EMPTY;
      }
  
      final StringBuilder sb = new StringBuilder();
  
      BufferedReader reader = null;
      try
      {
        if (charset != null)
        {
          reader = new BufferedReader(new InputStreamReader(is, charset));
        }
        else
        {
          reader = new BufferedReader(new InputStreamReader(is));
        }
  
        String line;
        while ((line = reader.readLine()) != null)
        {
          sb.append(line);
        }
      }
      finally
      {
        if (reader != null)
        {
          reader.close();
        }
      }
  
      return sb.toString();
    }
docs: To convert the InputStream to String we use the BufferedReader.readLine()
  method. We iterate until the BufferedReader return null which means
  there's no more data to read. Each line will appended to a StringBuilder
  and returned as String.
  
  @param is - InputStream
  @param charset - String, the character set
  @return String
  @throws IOException