Here you can find the source of getExternalIPAddress()
Returns external IP address by sending HTTP request to http://whatismyip.com/automation/n09230945.asp
public static String getExternalIPAddress()
//package com.java2s; //License from project: Open Source License import java.net.HttpURLConnection; public class Main { /**/*from w ww . j a v a 2s.c om*/ * Returns external IP address by sending HTTP request to http://whatismyip.com/automation/n09230945.asp * @return external IP address */ public static String getExternalIPAddress() { String url = null; try { java.net.URL URL = new java.net.URL("http://whatismyip.com/automation/n09230945.asp"); java.net.HttpURLConnection conn = (HttpURLConnection) URL.openConnection(); conn.setConnectTimeout(60000); conn.setReadTimeout(60000); java.io.InputStream InStream = conn.getInputStream(); java.io.InputStreamReader Isr = new java.io.InputStreamReader(InStream); java.io.BufferedReader br = new java.io.BufferedReader(Isr); url = br.readLine(); } catch (Exception e) { // } return url; } }