首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2SE开发 >

关于InetAddress.getByName,该怎么解决

2013-11-25 
关于InetAddress.getByNameInetAddress servertry {serverInetAddress.getByName(abcde.com)} catch(

关于InetAddress.getByName
InetAddress server;
try {server=InetAddress.getByName("abcde.com");} 
catch(Exception e) {System.out.println(e.toString());}

如果出现异常,那么 server==null 必然成立?
偶现在外出了,谢谢!

[解决办法]
当然不一定啦,如果楼主捕获的异常是空指针的话,那么server就是空的,但是并不一定异常就是空指针啊,所以具体情况视异常信息而定!

热点排行
Bad Request.