Code example for HttpURLConnection

Methods: disconnectsetInstanceFollowRedirectssetRequestMethodconnectgetHeaderFieldgetRequestProperties

0
	public boolean UpdateCheck(String urlStr) {
		boolean update = false;
		try { 
			URL url = new URL(urlStr);
			HttpURLConnection urlconn = (HttpURLConnection)url.openConnection();
			urlconn.setRequestMethod("GET");
			urlconn.setInstanceFollowRedirects(true);
			urlconn.getRequestProperties();
			urlconn.connect();
			String mETag = urlconn.getHeaderField("ETag");
			urlconn.disconnect();
			String ETag = GetPref("ETag");
			if (!ETag.equals(mETag)) {
				update = true;
				//if (mETag.equals("\"3401f-1fba4e-4c8c2d3f37100\"")) update = false; // for my tests (git) 
				//if (mETag.equals("\"1a6f2-affb8c-4b366f9fd3640\"")) update = false; // for my tests (stable) 
			} 
		} catch (Exception e) {
			e.printStackTrace();
		} 
Stop searching for code, let great code find you!  Add Codota to your java IDE