Here you can find the source of createImgUrlConnection(String url)
public static URLConnection createImgUrlConnection(String url) throws IOException
//package com.java2s; //License from project: Apache License import java.io.IOException; import java.net.URL; import java.net.URLConnection; public class Main { public static URLConnection createImgUrlConnection(String url) throws IOException { URLConnection conn = new URL(url).openConnection(); conn.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"); conn.setRequestProperty("Accept", "image/png,*/*;q=0.5"); conn.setRequestProperty("Accept-Language", "en-gb,en;q=0.5"); conn.setRequestProperty("Accept-Encoding", "gzip,deflate"); conn.setRequestProperty("Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.7"); return conn; }// w w w . ja v a 2 s. co m }