Here you can find the source of getHostName()
Parameter | Description |
---|---|
UnknownHostException | an exception |
public static String getHostName() throws UnknownHostException
//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(); } }