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 final String GetLocalHostName() 

Method Source Code

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

import java.net.*;

public class Main {
    public static final String GetLocalHostName() {
        String localHostName = "Unknown";
        try {/*from   ww w .j av a 2 s .  co  m*/
            InetAddress lhost = java.net.InetAddress.getLocalHost();
            localHostName = lhost.getHostName();
            if ("localhost".equals(localHostName))
                localHostName = lhost.getHostAddress();
        } catch (Exception e) {
            localHostName = "Unknown";
        }
        return localHostName;
    }
}

Related

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