Here you can find the source of getLocalAddress()
public static String getLocalAddress()
//package com.java2s; /******************************************************* * * * Copyright (C) 2011 Yahoo! Inc. All Rights Reserved. * * * * Licensed under the New * * BSD License. See the * * accompanying LICENSE file * * for the specific language * * governing permissions and * * limitations under the * * License. * *******************************************************/ import java.net.InetAddress; import java.net.UnknownHostException; public class Main { /**//from w w w .ja v a 2s .c o m * Gets the local address. * * @return the local address (or empty if error) */ public static String getLocalAddress() { try { InetAddress localMachine = InetAddress.getLocalHost(); return localMachine.getHostAddress(); } catch (UnknownHostException uhe) { return ""; } } }