public static void main(String[] args) {
		
		String rawTerm = "AIME";
		InputStream inputStream = null;
		DataInputStream dataStream;
		int intChar;
		StringBuilder str = new StringBuilder();
		
		try {
			
			String term = URLEncoder.encode(rawTerm,ENCODING);
			URL queryURL = new URL(ENDPOINT + term);
			inputStream = queryURL.openStream();
			dataStream = new DataInputStream(new BufferedInputStream(inputStream));
			while ((intChar = dataStream.read()) != -1) {
				str.append((char)intChar);
			}
			String result = str.toString();
			int countIndex = result.indexOf(RESULT_COUNT_ID);
			if (countIndex != -1) {
				result = result.substring(countIndex+RESULT_COUNT_ID.length());
				result = result.substring(0, result.indexOf('\"'));
				float count = Integer.parseInt(result)/1000000f;
				System.out.println("The key phrase: \"" + rawTerm + "\" has " + count + " million hits on Google.");
			}
			
		} catch (UnsupportedEncodingException e) {
			System.err.println("Error: " + ENCODING + " is not a valid encoding type.");
		} catch (MalformedURLException e) {
			System.err.println("Error: invalid query URL. Details below:");
			e.printStackTrace();
		} catch (IOException e) {
			System.err.println("Error: could not open a connection. Details below:");
			e.printStackTrace();
		}
		
		
	}