Code example for URL

Methods: openConnection

0
			// Replaces all spaces. 
			requestURL = requestURL.replaceAll(" ", "%20");
 
			TapjoyLog.i(TAPJOY_URL_CONNECTION, "requestURL: " + requestURL);
			 
			URL httpURL = new URL(requestURL);
			HttpURLConnection connection = (HttpURLConnection) httpURL.openConnection();
			connection.setConnectTimeout(15000);
			connection.setReadTimeout(30000);
			contentLength = connection.getHeaderField("content-length");
		} 
		catch (Exception e)
		{ 
			TapjoyLog.e(TAPJOY_URL_CONNECTION, "Exception: " + e.toString());
		} 
		 
		TapjoyLog.i(TAPJOY_URL_CONNECTION, "content-length: " + contentLength);
		 
		return contentLength;
	} 
Stop searching for code, let great code find you!  Add Codota to your java IDE