Here you can find the source of getLocalHost()
Parameter | Description |
---|---|
UnknownHostException | if localhost could not be resolved |
private static InetAddress getLocalHost() throws UnknownHostException
//package com.java2s; //License from project: Apache License import java.net.InetAddress; import java.net.UnknownHostException; public class Main { /**//w w w . ja v a 2 s. c o m * Methods returns InetAddress for localhost * * @return InetAddress of the localhost * @throws UnknownHostException if localhost could not be resolved */ private static InetAddress getLocalHost() throws UnknownHostException { InetAddress addr; try { addr = InetAddress.getLocalHost(); } catch (ArrayIndexOutOfBoundsException e) { //this is workaround for mac osx bug see AS7-3223 and JGRP-1404 addr = InetAddress.getByName(null); } return addr; } }