Java InetAddress Create getIP(InetAddress ip)

Here you can find the source of getIP(InetAddress ip)

Description

get IP

License

Creative Commons License

Declaration

public static String getIP(InetAddress ip) 

Method Source Code


//package com.java2s;
//License from project: Creative Commons License 

import java.net.InetAddress;

public class Main {
    public static String getIP(InetAddress ip) {
        return ip.getHostAddress().replace("/", "");
    }//from www.  jav a 2s .c  om

    public static String getIP(String ip) {
        ip = ip.replace("/", "");

        String[] withoutPort = ip.split(":");

        if (withoutPort.length == 2)
            return withoutPort[0];
        else
            return ip;
    }
}

Related

  1. getInetAddressFromString(String s)
  2. getInetAddressMap()
  3. getInetAddressMap()
  4. getInt32FromAddress(Inet4Address inetAddress)
  5. getInterface(InetAddress addr)
  6. getIP(InetAddress ip)
  7. getIP(InetAddress ip)
  8. getIPAsLong(InetAddress address)
  9. getIPAsString(InetAddress addr)