Java Host Name Get getCurrentHost()

Here you can find the source of getCurrentHost()

Description

get Current Host

License

Open Source License

Declaration

public static String getCurrentHost() 

Method Source Code

//package com.java2s;
/**//from   w w  w .j  a  v a  2 s . c o  m
 * Taken from apache hadoop project.
 * Apache 2.0 license.
 *
 * @param className
 * @return
 */

import java.net.InetAddress;

import java.net.UnknownHostException;

public class Main {
    public static String getCurrentHost() {
        String hostname = "localhost";
        try {
            hostname = InetAddress.getLocalHost().getHostName();
        } catch (UnknownHostException e) {
            e.printStackTrace();
        }
        return hostname;
    }
}

Related

  1. getCanonicalHostname()
  2. getCanonicalHostName()
  3. getCanonicalHostName()
  4. getCanonicalHostName()
  5. getCasServerHostName()
  6. getDefaultHostName()
  7. getFile(String host, String savePath)
  8. getFullHostname()
  9. getFullyQualifiedDomainName(String unqualifiedHostname)