Redian新闻
>
Help: UnknownHostException
avatar
Help: UnknownHostException# Java - 爪哇娇娃
u*e
1
我在程序里用到java.net.InetAddress.getLocalHost(),
却catch到UnknownHostException。
请问什么状况下有可能发生?有没有work around? 谢谢
avatar
m*t
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? 谢谢

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。