Man*_*áoz 16 java ip bytearray
假设我有一个存储在字符串中的IP:
String ip ="192.168.2.1"
我想得到四个整数的字节数组.我该怎么做?谢谢!
Inv*_*r53 40
像这样的东西:
InetAddress ip = InetAddress.getByName("192.168.2.1");
byte[] bytes = ip.getAddress();
for (byte b : bytes) {
System.out.println(b & 0xFF);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
33465 次 |
| 最近记录: |