Here you can find the source of getLocalAddress()
static String getLocalAddress()
//package com.java2s; //License from project: Apache License import java.net.InetAddress; import java.net.UnknownHostException; public class Main { static String getLocalAddress() { try {/*from w ww.ja va 2 s.c o m*/ return InetAddress.getLocalHost().getHostAddress(); } catch (UnknownHostException e) { try { return InetAddress.getLocalHost().getHostName(); } catch (UnknownHostException e1) { return "localhost"; } } } }