u**********e 发帖数: 282 | 1 我在程序里用到java.net.InetAddress.getLocalHost(),
却catch到UnknownHostException。
请问什么状况下有可能发生?有没有work around? 谢谢 | m******t 发帖数: 2416 | 2
RTFM:
getLocalHost
public static InetAddress getLocalHost() throws UnknownHostException
Returns the local host.
If there is a security manager, its checkConnect method is called with the
local host name and -1 as its arguments to see if the operation is allowed. If
the operation is not allowed, an InetAddress representing the loopback address
is returned.
Returns:
the IP address of the local host.
Throws:
UnknownHostException - if no IP address for the host could be found.
See Also:
SecurityMan
【在 u**********e 的大作中提到】 : 我在程序里用到java.net.InetAddress.getLocalHost(), : 却catch到UnknownHostException。 : 请问什么状况下有可能发生?有没有work around? 谢谢
|
|