After reading: Getting an "external" IP address in Java
the code:
public static void main(String[] args) throws IOException
{
URL whatismyip = new URL("http://automation.whatismyip.com/n09230945.asp");
BufferedReader in = new BufferedReader(new InputStreamReader(whatismyip.openStream()));
String ip = in.readLine();
System.out.println(ip);
}
I thought I was a winner, but I get the following error
Exception in thread "main" java.io.IOException: Server returned HTTP response code: 403 for URL: http:
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at java.net.URL.openStream(Unknown Source)
at getIP.main(getIP.java:12)
I think this is because the server is not responding fast enough, is there anyway to get an external ip?
EDIT: ok, so its rejection, someone else knows about another site that can perform the same function
source
share