java中如何实例化一个InetAddress对象呢?
下文笔者讲述实例化一个InetAddress对象的方法分享,如下所示
实现思路: 使用InetAddress.getByName 或 InetAddress.getByAddress 即可返回一个InetAddress对象例
InetAddress addr = InetAddress.getByName("127.0.0.1"); 或 使用字节数组的方式返回InetAddress对象 byte[] ipAddr = new byte[]{127, 0, 0, 1}; InetAddress addr = InetAddress.getByAddress(ipAddr);
版权声明
本文仅代表作者观点,不代表本站立场。
本文系作者授权发表,未经许可,不得转载。