class NetworkUtil {

    public static String getLocalHostIp() {
        InetAddress address;
        String hostAddress;
        try {
            address = InetAddress.getLocalHost();
            // force a best effort reverse DNS lookup
            hostAddress = address.getHostAddress();
            if (StringUtil.isEmpty(hostAddress)) {
                hostAddress = address.toString();
            }
        } catch (UnknownHostException noIpAddrException) {
            hostAddress = LOCALHOST;
        }
        return hostAddress;
    }

}