Java Host Name Get getShortHostName()

Here you can find the source of getShortHostName()

Description

get Short Host Name

License

Open Source License

Declaration

public static String getShortHostName() 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.net.*;

public class Main {
    public static String getShortHostName() {
        String name = getHostName();
        int i = name.indexOf('.');
        if (i == -1)
            return name;
        return name.substring(0, i);
    }/*from  ww  w.  ja  v  a 2s.co  m*/

    public static String getHostName() {
        try {
            return InetAddress.getLocalHost().getHostName();
        } catch (UnknownHostException e) {
            return "(unknown)";
        }
    }
}

Related

  1. getMachineHostname()
  2. getMyHostname()
  3. getProxy(String host, String proxyType)
  4. getServerHost()
  5. getShortHostName()
  6. getShortHostname()
  7. getShortHostname()
  8. getTimerServerHost()