Here you can find the source of getInetIpAddress()
public static String getInetIpAddress()
//package com.java2s; import java.net.InetAddress; import java.net.NetworkInterface; import java.util.Enumeration; public class Main { public static String getInetIpAddress() { try {/* w w w.j a va 2s .c o m*/ for (Enumeration<NetworkInterface> en = NetworkInterface .getNetworkInterfaces(); en.hasMoreElements();) { NetworkInterface intf = en.nextElement(); for (Enumeration<InetAddress> ipAddr = intf .getInetAddresses(); ipAddr.hasMoreElements();) { InetAddress inetAddress = ipAddr.nextElement(); return inetAddress.getHostAddress(); } } } catch (Exception e) { e.printStackTrace(); } return null; } }