Code example for HttpURLConnection

Methods: setRequestMethodgetDatesetConnectTimeoutsetReadTimeout

0
		return this.connection.getHeaderFieldKey(n);
	} 
	 
	public long getDate() throws IOException { 
		connect(); 
		return this.connection.getDate();
	} 
	 
	public long getExpiration() throws IOException { 
		connect(); 
		return this.connection.getExpiration();
	} 
	 
	public long getLastModified() throws IOException { 
		connect(); 
		return this.connection.getLastModified();
	} 
	 
	protected synchronized void connect() throws IOException { 
		if (this.state == STATE_CONNECTED) {
			if(this.connection == null) {
				throw new IOException("Invalid State. No connection in state STATE_CONNECTED");
			} 
			return; 
		} else { 
			this.state = STATE_CONNECTED;
		} 
	//	//#if polish.android.http.keepAlive != true 
	//		//#= System.setProperty("http.keepAlive", "false"); 
	//	//#endif 
		this.connection = (HttpURLConnection)this.url.openConnection();
		if (this.timeout > 0) {
			this.connection.setConnectTimeout(this.timeout);
			this.connection.setReadTimeout(this.timeout);
		} 
		this.connection.setRequestMethod(this.requestMethod);
	} 
	 
}	 
Stop searching for code, let great code find you!  Add Codota to your java IDE