Code example for URLConnection

Methods: addRequestPropertygetContentsetUseCaches

0
		 
		URLConnection connection;
		InputStream is = null;
		try { 
			connection = url.openConnection();
			connection.setUseCaches(true);
			if (cookies != null) {
				connection.addRequestProperty("Cookie", cookies);
			} 
			is = (InputStream)connection.getContent();
		} catch (IOException e) {
			// TODO 自动生成的 catch 块 
			e.printStackTrace();
		} 
		return BitmapFactory.decodeStream(is);
	} 
	 
	public static void loadImage(final URL url, final String cookies) {
		if (url == null)
			return; 
Stop searching for code, let great code find you!  Add Codota to your java IDE