Java URL Connection createImgUrlConnection(String url)

Here you can find the source of createImgUrlConnection(String url)

Description

create Img Url Connection

License

Apache License

Declaration

public static URLConnection createImgUrlConnection(String url) throws IOException 

Method Source Code

//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
}

Related

  1. addHeaders(Map headers, URLConnection c)
  2. addHeaders(URLConnection conn)
  3. addProperty(URLConnection connection)
  4. byteArrayToURL(final byte[] bytes)
  5. closeURLClassLoader(URLClassLoader clazzLdr)
  6. createURLClassLoader(String dirPath)
  7. createURLConnection(String url)
  8. createWebStartDirectory(String name, String jarUrl)
  9. doGet(String targetURL)