Java IP Address Get getLocalHostIp()

Here you can find the source of getLocalHostIp()

Description

get Local Host Ip

License

Apache License

Declaration

public static String getLocalHostIp() 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.net.InetAddress;

import java.net.UnknownHostException;

public class Main {
    public static String getLocalHostIp() {
        String ip = "";
        InetAddress inetAddress;//w  w  w .  j av a2  s. c om
        try {
            inetAddress = InetAddress.getByName("localhost");
            ip = inetAddress.getHostAddress();
        } catch (UnknownHostException e) {
            throw new RuntimeException("Is your network broken; localhost does not exist?", e);
        }
        return ip;
    }
}

Related

  1. getLinuxIPAddress()
  2. getLocalAddresses(boolean ipv4only)
  3. getLocalHostIP()
  4. getLocalHostIp()
  5. getLocalhostIp()
  6. getLocalHostIPAdress()
  7. getLocalHostIps()
  8. getLocalHostIps()
  9. getLocalIp()