.liyh.utils;Address;.NetworkInterface;.SocketException;.UnknownHostException;importjava.util.ArrayList;importjava.util.Enumeration;importjava.util.List;/***本地主机工具类
publicstaticStringgetHostName()throwsUnknownHostException{Address.getLocalHost().getHostName();
publicstaticStringgetLocalIP()throwsUnknownHostException{Address.getLocalHost().getHostAddress();
publicstaticString[]getLocalIPs()throwsSocketException{
Enumerationenumeration=NetworkInterface.getNetworkInterfaces();while(enumeration.hasMoreElements()){
NetworkInterfaceintf=enumeration.nextElement();if(intf.isLoopback()||intf.isVirtual()){//continue;
Addressaddr=s.nextElement();if(addr.isLoopbackAddress()||!addr.isSiteLocalAddress()||addr.isAnyLocalAddress()){continue;
publicstaticbooleanisWindowsOS(){booleanisWindowsOS=false;
StringosName=System.getProperty("os.name");if(osName.toLowerCase().indexOf("windows")>-1){
System.out.println("主机是否为Windows系统:" LocalHostUtil.isWindowsOS());
System.out.println("主机名称:" LocalHostUtil.getHostName());
System.out.println("系统首选IP:" LocalHostUtil.getLocalIP());
System.out.println("系统所有IP:" String.join(",",LocalHostUtil.getLocalIPs()));
1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。