Here you can find the source of getHostName(String host)
public static String getHostName(String host) throws UnknownHostException
//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(); } }