Java Host Name Get getCasServerHostName()

Here you can find the source of getCasServerHostName()

Description

Gets cas server host name.

License

Apache License

Return

the cas server host name

Declaration

public static String getCasServerHostName() 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.net.InetAddress;

public class Main {
    /**//ww w. ja  va 2s. c o m
     * Gets cas server host name.
     *
     * @return the cas server host name
     */
    public static String getCasServerHostName() {
        try {
            final String hostName = InetAddress.getLocalHost().getCanonicalHostName();
            final int index = hostName.indexOf('.');
            if (index > 0) {
                return hostName.substring(0, index);
            }
            return hostName;
        } catch (final Exception e) {
            throw new IllegalArgumentException("Host name could not be determined automatically.", e);
        }
    }
}

Related

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