Java Host Name Get getHostName()

Here you can find the source of getHostName()

Description

Returns the hostname of the current host

License

Open Source License

Exception

Parameter Description
UnknownHostException an exception

Return

Hostname

Declaration

public static String getHostName() throws UnknownHostException 

Method Source Code

//package com.java2s;

import java.net.InetAddress;
import java.net.UnknownHostException;

public class Main {
    /** Returns the hostname of the current host
     * @return Hostname// ww  w.ja  v a2  s.  com
     * @throws UnknownHostException
     */
    public static String getHostName() throws UnknownHostException {
        return InetAddress.getLocalHost().getHostName();
    }
}

Related

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