Java Host Name Get getHost(String host)

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

Description

Returns the host address, if the supplied host is localhost, else returns it, unchanged.

License

Open Source License

Declaration

private static String getHost(String host) 

Method Source Code

//package com.java2s;
import java.net.InetAddress;
import java.net.UnknownHostException;

public class Main {
    /**/*from   ww  w  .  ja  v  a 2 s.  c om*/
     * Returns the host address, if the supplied host is localhost, else returns
     * it, unchanged.
     */
    private static String getHost(String host) {
        if (host.equals("localhost")) {
            try {
                host = InetAddress.getLocalHost().getHostAddress();
            } catch (UnknownHostException ignore) {
            }
        }
        return host;
    }
}

Related

  1. getFullHostname()
  2. getFullyQualifiedDomainName(String unqualifiedHostname)
  3. getFullyQualifiedHostName()
  4. getHost()
  5. getHost()
  6. getHost(String link)
  7. getHost(String s)
  8. getHostCore(final String quadGraph)
  9. getHostGateway()