Here you can find the source of getLocalAddress()
public static String getLocalAddress()
//package com.java2s; import java.net.*; public class Main { public static String getLocalAddress() { String addr = null;//from w w w . ja v a 2s . c o m try { InetAddress ia = InetAddress.getLocalHost(); if (ia != null) addr = ia.getHostAddress(); } catch (UnknownHostException uhe) { } return addr; } }