java ip类
InetAddress
package com.example.network;
import java.net.InetAddress;
import java.net.UnknownHostException;
public class TestIp {
    public static void main(String[] args) throws UnknownHostException {
        // 有一个类InetAddress 是ip类
        // 获取本体ip
        System.out.println(InetAddress.getByName("127.0.0.1")); // /127.0.0.1
        System.out.println(InetAddress.getByName("localhost"));// localhost/127.0.0.1
        System.out.println(InetAddress.getLocalHost());// DESKTOP-UO9DFUU/10.182.121.91
        // 获取百度ip
        InetAddress inetAddress = InetAddress.getByName("www.baidu.com");
        System.out.println(inetAddress.getAddress()); // [B@681a9515
        System.out.println(inetAddress.getHostAddress()); // 14.215.177.38
        System.out.println(inetAddress.getCanonicalHostName()); // 14.215.177.38
        System.out.println(inetAddress.getHostName()); // www.baidu.com
    }
}