Here you can find the source of getLocalAddress()
public static String getLocalAddress()
//package com.java2s; //License from project: Apache License import java.net.InetAddress; import java.net.UnknownHostException; public class Main { public static String getLocalAddress() { InetAddress inetAddress = null; try {/* w w w. ja va2s. c o m*/ inetAddress = InetAddress.getLocalHost(); } catch (UnknownHostException e) { e.printStackTrace(); } return inetAddress.getHostAddress(); } }