Java Local Host Get getLocalHostName()

Here you can find the source of getLocalHostName()

Description

get Local Host Name

License

Open Source License

Declaration

public static String getLocalHostName() 

Method Source Code

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

import java.net.InetAddress;

import java.net.UnknownHostException;

public class Main {
    public static String getLocalHostName() {
        try {//from   w  w  w  . j  av a  2  s .  c o  m
            return (InetAddress.getLocalHost()).getHostName();
        } catch (UnknownHostException uhe) {
            String host = uhe.getMessage();
            if (host != null) {
                int colon = host.indexOf(':');
                if (colon > 0) {
                    return host.substring(0, colon);
                }
            }
            return "UnknownHost";
        }
    }
}

Related

  1. getLocalHostName()
  2. getLocalHostName()
  3. getLocalHostName()
  4. GetLocalHostName()
  5. getLocalHostName()
  6. getLocalHostName()
  7. getLocalHostname()
  8. getLocalHostName()
  9. getLocalHostName()