Java Local Host Get getLocalHostName()

Here you can find the source of getLocalHostName()

Description

Gets the host name for the local machine.

License

Open Source License

Return

A string with the local hostname or null on error.

Declaration

public static String getLocalHostName() 

Method Source Code

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

public class Main {
    /**/*  w  ww.j  a  v  a 2 s.  c  o m*/
     * Gets the host name for the local machine.
     *
     * @return A string with the local hostname or null on error.
     */
    public static String getLocalHostName() {

        java.net.InetAddress addr = null;
        try {
            addr = java.net.InetAddress.getLocalHost();
        } catch (Exception ignore) {
            return (null);
        }

        return (addr.getHostName());
    }
}

Related

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