Here you can find the source of getLocalhost()
Parameter | Description |
---|---|
RuntimeException | When we cannot determine the local machine's hostname |
public static String getLocalhost() throws RuntimeException
//package com.java2s; //License from project: Open Source License import java.net.InetAddress; import java.net.UnknownHostException; public class Main { /**// www.j av a 2s. c o m * Gets the hostname of localhost * * @return String * * @throws RuntimeException * When we cannot determine the local machine's hostname */ public static String getLocalhost() throws RuntimeException { String hostname = null; try { InetAddress addr = InetAddress.getLocalHost(); hostname = addr.getHostName(); } catch (UnknownHostException e) { throw new RuntimeException("[FileHelper] {getLocalhost}: Can't get local hostname"); } return hostname; } }