Here you can find the source of getLocalAddress()
public static String getLocalAddress()
//package com.java2s; //License from project: Open Source License import java.net.*; public class Main { /**// www. j av a2 s. co m * This method returns the local IP address as a String. If for some reason * the local IP address can't be determined it returns <code>0.0.0.0</code> * <p> * An example of a situation where the local IP address can't be determined * is a machine without a network config and not connected to the internet * with a modem. */ public static String getLocalAddress() { try { return InetAddress.getLocalHost().getHostAddress(); } catch (Exception ex) { return "0.0.0.0"; } } /** * Gets the local machines host name if it has one. If it does not have a * local host name then localhost is returned. */ public static String getLocalHost() { try { return InetAddress.getLocalHost().getHostName(); } catch (Exception _ex) { return "localhost"; } } }