Java IP Address Get getIpByHost(String hostName)

Here you can find the source of getIpByHost(String hostName)

Description

get Ip By Host

License

Apache License

Declaration

public static String getIpByHost(String hostName) 

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 getIpByHost(String hostName) {
        try {/* w w w .j  a v  a  2 s  .c  o m*/
            return InetAddress.getByName(hostName).getHostAddress();
        } catch (UnknownHostException e) {
            return hostName;
        }
    }
}

Related

  1. getIpAddressExternal()
  2. getIPAddressFromBytes(byte[] bytes)
  3. getIPAddressFromNetworkInterface(String ifaceName)
  4. getIPAddressFromNetworkInterfaces()
  5. getIPAdresses()
  6. getIpByHost(String hostName)
  7. getIpByHost(String hostName)
  8. getIPByInterfaceName(String name)
  9. getIpByName(String name)