The approved answer will work ... if you know your proxy host and port =) . But in case you are looking for the proxy host and port the steps below should help
if auto configured proxy is given: then
1> open IE(or any browser)
2> get the url address from your browser through IE->Tools->internet
option->connections->LAN Settings-> get address and give in url eg: as
http://autocache.abc.com/ and enter, a file will be downloaded with
.pac format, save to desktop
3> open .pac file in textpad, identify PROXY:
In your editor, it will come something like:
return "PROXY web-proxy.ind.abc.com:8080; PROXY
proxy.sgp.abc.com:8080";
kudos to bekur from maven in 5 min not working
Once you have the host and port just pop in into this and your good to go
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("web-proxy.ind.abc.com", 8080));
URLConnection connection = new URL(url).openConnection(proxy);