public static String readStreamToString(InputStream is) throws IOException
   {
      StringBuilder result = new StringBuilder();

      byte[] buffer = new byte[1024];
      while (true)
      {
         int bytesRead = is.read(buffer);
         if (bytesRead == -1)
         {
            break;
         }

         result.append(new String(buffer, 0, bytesRead));
      }

      return result.toString();
   }