abhinav90
asked on
java.net unable to connect to URL
I am trying to connect to a url using java.net to connect to a url but it keeps giving me an UnknownHostException: www.yahoo.com. I have tried everything. The firewall is not blocking java, i am able to ping the website from the computer running the code. I also tested with adding a line for proxy's to allow for the connection but that did not work either. I tried some other websites hosted on my servers as well but with no luck.
import java.net.*;
import java.io.*;
public class URLconnectionReader {
public static void main(String[] args) throws Exception {
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("77.95.208.230", 8080));
URL yahoo = new URL("http://www.yahoo.com/");
URLConnection yc = yahoo.openConnection();
BufferedReader in = new BufferedReader(
new InputStreamReader(
yc.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null)
System.out.println(inputLine);
in.close();
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER