try {
   URL url = new URL(”http://www.byu.edu/”);
   
   HttpURLConnection connection = (HttpURLConnection)url.openConnection();
   
   connection.setRequestMethod(”GET”);
   
   // Set HTTP request headers, if necessary
   // connection.addRequestProperty(”Accept”, ”text/html”);
   
   connection.connect();
   
   if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) {
      // Get HTTP response headers, if necessary
      // Map<String, List<String>> headers = connection.getHeaderFields();

	  // Get response body input stream
      InputStream responseBody = connection.getInputStream();
	  
      // Read response body bytes
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      byte[] buffer = new byte[1024];
      int length = 0;
      while ((length = responseBody.read(buffer)) != -1) {
         baos.write(buffer, 0, length);
      }
	  
	  // Convert response body bytes to a string
	  String responseBodyData = baos.toString();
	  
	  // TODO: Process response body data
	  // ...
   }
   else {
      // SERVER RETURNED AN HTTP ERROR
   }
}
catch (IOException e) {
   // IO ERROR
} 
