Here you can find the source of getIPAddr()
public static String getIPAddr()
//package com.java2s; import java.net.InetAddress; import java.net.UnknownHostException; public class Main { public static String getIPAddr() { InetAddress Address = null; try {/*from w w w . j a va 2 s . com*/ Address = InetAddress.getLocalHost(); } catch (UnknownHostException e) { e.printStackTrace(); } return Address.getHostAddress(); } }