List of utility methods to do URLConnection Create
URLConnection | openConnection(final URL url) open Connection URLConnection conn = url.openConnection();
conn.setReadTimeout(3000);
conn.setDefaultUseCaches(false);
conn.setUseCaches(false);
return conn;
|
URLConnection | openConnection(String urlPath) open Connection try { URL url = new URL(urlPath); return url.openConnection(); } catch (IOException ex) { throw new UncheckedIOException(ex); |
URLConnection | openConnection(URL localURL) open Connection URLConnection connection; if (proxyHost != null && proxyPort != null) { Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxyHost, proxyPort)); connection = localURL.openConnection(proxy); } else { connection = localURL.openConnection(); return connection; ... |
URLConnection | openConnection(URL url) open Connection try { URLConnection connection = url.openConnection(); connection.setUseCaches(false); return connection; } catch (IOException e) { throw new IllegalStateException(e); |
URLConnection | openConnection(URL url) Opens a url with read and connect timeouts URLConnection connection = url.openConnection();
connection.setConnectTimeout(SOCKET_TIMEOUT);
connection.setReadTimeout(SOCKET_TIMEOUT);
return connection;
|
URLConnection | openConnection(URL url) opens a connection to a url and adds the headers (see below) you should use this instead of the method in the URL class URLConnection conn = url.openConnection();
addHeaders(conn);
return conn;
|
URLConnection | openConnection(URL url) open Connection long timeoutExpiredMs = System.currentTimeMillis() + WAIT_TIME; URLConnection jaggeryServerConnection = null; try { jaggeryServerConnection = url.openConnection(); } catch (IOException ignored) { while ((jaggeryServerConnection == null) && (System.currentTimeMillis() <= timeoutExpiredMs)) { try { ... |
URLConnection | openConnectionForceNoProxy(URL url) open Connection Force No Proxy return url.openConnection(Proxy.NO_PROXY);
|
URLConnection | openConnectionTo(URL descriptor) Checks that descriptor exist, is a file and is readable URLConnection conn; try { conn = descriptor.openConnection(); } catch (IOException e) { throw new IllegalArgumentException( "Connection to " + descriptor.toExternalForm() + " could not be established.", e); return conn; ... |
InputStream | openInputStream(URL url) open Input Stream URLConnection uRLConnection = url.openConnection(); uRLConnection.setRequestProperty("User-Agent", "Valve/Steam HTTP Client 1.0 (tenfoot)"); uRLConnection.setRequestProperty("Cookie", "birthtime=-3599; lastagecheckage=1-January-1970"); uRLConnection.setConnectTimeout(8000); uRLConnection.setReadTimeout(8000); return uRLConnection.getInputStream(); |