Java IP Address Get getIp()

Here you can find the source of getIp()

Description

get Ip

License

Open Source License

Declaration

public static String getIp() 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

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

public class Main {
    public static String getIp() {
        InetAddress ip;//from   w w  w.j  av  a2  s  . co  m

        try {
            ip = InetAddress.getLocalHost();
            return ip.getHostAddress();
        } catch (UnknownHostException e) {
            e.printStackTrace();
        }

        return "localhost";
    }
}

Related

  1. getIP()
  2. getIp()
  3. getIp()
  4. getIp()
  5. getIp()
  6. getIP()
  7. getIp()
  8. getIP()
  9. getIp()