import java.net.InetAddress; import java.net.UnknownHostException; import java.util.Arrays; public class helloworld { public static void main(String[] args) throws UnknownHostException { InetAddress ip = InetAddress.getByAddress(new byte[]{10,1,1,1}); System.out.println(ip); ip = InetAddress.getByAddress("www.sdut.edu.cn", new byte[]{10,1,1,1}); System.out.println(ip); ip = InetAddress.getByName("www.qq.com"); System.out.println(ip); ip = InetAddress.getLocalHost(); System.out.println(ip); System.out.println(ip.getHostName()); System.out.println(Arrays.toString(ip.getAddress())); } }
ip java
猜你喜欢
转载自blog.csdn.net/shadowam/article/details/80222712
今日推荐
周排行