日期:2014-05-17  浏览次数:20741 次

求教,如何获取局域网的IP?
家里用的是无线局网,可我用 InetAddress.getLocalHost().getHostAddress()得到的是外网IP:172.XX.0.xxx

怎么才能把内网IP192.168.11.2的出来啊?

------解决方案--------------------
外层的应该是: return null;

一般用null表示找不到,比如你的程序运行时,恰好网卡都被禁用了,就1个都找不到了。