I am trying to create URL connection using a proxy at run time. My code is below:
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("192.0.2.100", 80));
HttpURLConnection connection =
(HttpURLConnection)new URL("http://abc.example.com").openConnection(proxy);
But this is not working. Anybody know why?
adding answer for the help of future visitors
dku.rajkumar's way doesn't work with me.
I try this and it work. But it takes double time.
the result is true
without
((HttpURLConnection)new URL("http://abc.example.com").openConnection(proxy)).getInputStream();
the result is false