• Codota
    • All Android classes
    • All Java 8 classes
    • All Spring Framework classes
  • Get Codota for Java

Copy the selected text by pressing ctrl+c

 

Code example for HttpURLConnection

Methods: disconnect, addRequestProperty, connect, getInputStream, getOutputStream, setConnectTimeout, setDoOutput, setReadTimeout

0
githubopenproject/world: NetworkManager.java
Save Full Code
			} 
			else 
			{ 
				httpConnect = (HttpURLConnection) url.openConnection();
			} 
			httpConnect.setConnectTimeout( connectTimeout );
			httpConnect.setReadTimeout( readTimeout );
			httpConnect.setDoOutput(true);
			httpConnect.addRequestProperty("Content-type", "application/x-www-form-urlencoded;charset=utf-8");
			 
			httpConnect.connect();
			 
			OutputStream os = httpConnect.getOutputStream();
			p_entity.writeTo(os);
			os.flush();
 
			InputStream content 	= httpConnect.getInputStream();
			strResponse 	 	= BaseHelper.convertStreamToString(content);
			BaseHelper.log(TAG, "response " + strResponse);
		} 
		catch (IOException e)
		{ 
			e.printStackTrace();
		} 
		finally 
		{ 
			httpConnect.disconnect();
		} 
		 
		return strResponse;
	}	 
	 
Add Tag...Class HttpURLConnectionPackage java.net
7
CodeRank
HttpURLConnection.setConnectTimeout(int)HttpURLConnection.setReadTimeout(int)HttpURLConnection.disconnect()HttpURLConnection.setDoOutput(1)HttpURLConnection.addRequestProperty("Content-type","application/x-www-form-urlencoded;charset=utf-8")HttpURLConnection.getInputStream()StartHttpURLConnection.connect()HttpURLConnection.getOutputStream()

Other popular examples for HttpURLConnection

githubCode example from Github project apache/activemq, RestFilterTest.java »
40:	connection.setRequestMethod("PUT"); 
41:	connection.setDoOutput(true); 
42:	connection.setChunkedStreamingMode(fileContents.length); 
43:	OutputStream os = connection.getOutputStream(); 
-
46:	assertTrue(isSuccessfulCode(connection.getResponseCode())); 
47:	connection.disconnect(); 
Full Snippet Info
10
CodeRank
Add Tag...
githubCode example from Github project phonegap/phonegap-plugins, HttpHelper.java »
98:	connection.setRequestProperty("Accept", contentTypes); 
99:	connection.setRequestProperty("Accept-Charset", "utf-8,*"); 
100:	connection.setRequestProperty("User-Agent", "ZXing (Android)"); 
-
103:	connection.connect(); 
-
115:	responseCode = connection.getResponseCode(); 
-
127:	connection.disconnect(); 
Full Snippet Info
10
CodeRank
Add Tag...
githubCode example from Github project webbit/webbit, HttpClient.java »
50:	urlConnection.addRequestProperty("Content-Encoding", "gzip"); 
51:	urlConnection.setRequestMethod("POST"); 
52:	urlConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); 
53:	urlConnection.setDoOutput(true); 
-
60:	urlConnection.getOutputStream().write(baos.toByteArray()); 
Full Snippet Info
9
CodeRank
Add Tag...
More code examples for HttpURLConnection »