Java IP Address Get getIPAddress()

Here you can find the source of getIPAddress()

Description

get IP Address

License

Apache License

Return

the IP address of the machine

Declaration

public static String getIPAddress() 

Method Source Code

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

import java.net.InetAddress;
import java.net.UnknownHostException;

public class Main {
    /**//from  ww w.  j a v  a2  s .com
     * @return the IP address of the machine
     */
    public static String getIPAddress() {
        InetAddress inetAddress = null;
        try {
            inetAddress = InetAddress.getLocalHost();
        } catch (UnknownHostException ex) {
            // ignore
        }
        return (inetAddress == null ? "<unknown>" : inetAddress.getHostAddress());
    }
}

Related

  1. getIpAddress()
  2. getIpAddress()
  3. getIpAddress()
  4. getIpAddress()
  5. getIpAddress()
  6. getIPAddress()
  7. getIPAddress()
  8. getIpAddress()
  9. getIpAddress()