code: private static String inputStreamToString(InputStream stream)
  			throws IOException {
  		ByteArrayOutputStream result = new ByteArrayOutputStream();
  		byte[] buffer = new byte[1024];
  		int length;
  		String resultString = null;
  		while ((length = stream.read(buffer)) != -1) {
  			result.write(buffer, 0, length);
  		}
  		resultString = result.toString("UTF-8");
  		return resultString;
  	}
docs: Utility method which converts an InputStream to a String.
  
  @param stream
  the InputStream to convert.
  @return a String with the InputStream content.
  @throws IOException
  Signals that an I/O exception has occurred.