搜题
问题   更新时间2023/4/3 12:59:00

获取本机的IP地址

import java.net.InetAddress; import java.net.UnknownHostException; public class getLocalHostTest { public static void main(String[] args) { InetAddress myIP=null; try { myIP=InetAddress.getLocalHost(); System.out.println(myIP.getHostAddress()); }catch (UnknownHostException e) { System.out.println(); } } }
王老师:19139051760(拨打)