Java IP Address Get getIPAddress()

Here you can find the source of getIPAddress()

Description

get IP Address

License

Apache License

Declaration

public static synchronized String getIPAddress() 

Method Source Code

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

import java.net.*;

public class Main {
    private static String gLocalIPAddress;

    public static synchronized String getIPAddress() {
        if (gLocalIPAddress != null)
            return (gLocalIPAddress);
        try {/*from ww w.jav a2 s. c  o  m*/
            InetAddress address = InetAddress.getLocalHost();
            return (address.getHostAddress());
        } catch (UnknownHostException e) {
            return ("");
        }
    }
}

Related

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