Java Host Name Get getHostName(String host)

Here you can find the source of getHostName(String host)

Description

get Host Name

License

Open Source License

Declaration

public static String getHostName(String host) throws UnknownHostException 

Method Source Code

//package com.java2s;

import java.net.InetAddress;

import java.net.UnknownHostException;

public class Main {
    /** Returns the hostname of the current host
     * @return Hostname//from  w w w . j  a  v a  2s . co m
     * @throws UnknownHostException
     */
    public static String getHostName() throws UnknownHostException {
        return InetAddress.getLocalHost().getHostName();
    }

    public static String getHostName(String host) throws UnknownHostException {
        return InetAddress.getByName(host).getCanonicalHostName();
    }
}

Related

  1. getHostname()
  2. getHostname()
  3. getHostName()
  4. getHostName(Proxy proxy)
  5. getHostName(String destination)
  6. getHostname(String targetEndpoint)
  7. getHostNameByInet()
  8. getHostNameByNic()
  9. getHtmlSource(final String host)