您的位置:首页 > 编程语言 > Java开发

Java InetAddress.getByAddress()的使用

2015-01-29 11:48 363 查看
import java.net.*;

public class NetDemo {

public static void main(String[] args) throws Exception{

String str = "172.20.223.120";
String[] ipStr = str.split("\\.");
byte[] ipBuf = new byte[4];
for(int i = 0; i < 4; i++){
ipBuf[i] = (byte)(Integer.parseInt(ipStr[i])&0xff);
}

InetAddress ia = InetAddress.getByAddress("hao.wen",ipBuf);
System.out.println(ia);
}
}
转自/article/6959335.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: