0
点赞
收藏
分享

微信扫一扫

Java 把linux hostname 的byte[]转成String

凶猛的小白兔 2022-07-27 阅读 177


byte[] ip =InetAddress.getByName(host)
                                   .getAddress();
String ipStr = new StringBuffer().append(ip[0] & 0xFF)
                                             .append('.')
                                             .append(ip[1] & 0xFF)
                                             .append('.')
                                             .append(ip[2] & 0xFF)
                                             .append('.')
                                             .append(ip[3] & 0xFF)
                                             .toString();

举报

相关推荐

0 条评论