Here you can find the source of getInternetIpAddress()
public static String getInternetIpAddress() throws Exception
//package com.java2s; //License from project: Open Source License import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.URL; public class Main { public static String getInternetIpAddress() throws Exception { URL oUrl = new URL("http://checkip.amazonaws.com"); BufferedReader brINPUT = null; try {//from www . ja va 2 s .c o m brINPUT = new BufferedReader(new InputStreamReader(oUrl.openStream())); String strReturnIP = brINPUT.readLine(); return strReturnIP; } finally { if (brINPUT != null) { try { brINPUT.close(); } catch (IOException e) { e.printStackTrace(); } } } } }