Here you can find the source of getIPAddress()
public static String getIPAddress()
//package com.java2s; //License from project: Apache License import java.net.InetAddress; import java.net.UnknownHostException; public class Main { /**//from ww w. j a v a2 s .com * @return the IP address of the machine */ public static String getIPAddress() { InetAddress inetAddress = null; try { inetAddress = InetAddress.getLocalHost(); } catch (UnknownHostException ex) { // ignore } return (inetAddress == null ? "<unknown>" : inetAddress.getHostAddress()); } }