Java IP Address Get getLocalIP()

Here you can find the source of getLocalIP()

Description

get Local IP

License

Apache License

Declaration

public static String getLocalIP() 

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 getLocalIP() {
        try {/*from w w  w. j a  v  a 2  s . c  o  m*/
            InetAddress localHost = InetAddress.getLocalHost();
            String hostAddress = localHost.getHostAddress();
            return hostAddress;
        } catch (UnknownHostException e) {
            throw new RuntimeException(e);
        }
    }
}

Related

  1. getLocalIP()
  2. getLocalIp()
  3. getLocalIp()
  4. getLocalIP()
  5. getLocalIP()
  6. getLocalIP()
  7. getLocalIp()
  8. getLocalIp(final boolean useIpv6)
  9. getLocalIPAddress()