真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

java輸出服務(wù)器的mac地址-創(chuàng)新互聯(lián)

import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;

public class PrintServerMacInfo {

    private static ListgetMacAddress4Linux() throws Exception {
        ListmacAddressList = new ArrayList<>();
        ListinetAddresses = getLocalAllInetAddress();
        if (inetAddresses != null && inetAddresses.size() >0) {
            for( InetAddress inetAddress:inetAddresses ) {
                String macAddress = getMacByInetAddress(inetAddress);
                macAddressList.add( macAddress );
            }
        }
        return macAddressList;
    }

    private static ListgetMacAddress4Windows() throws Exception {
        ListmacAddressList = new ArrayList<>();
        ListinetAddresses = getLocalAllInetAddress();
        if (inetAddresses != null && inetAddresses.size() >0) {
            for( InetAddress inetAddress:inetAddresses ){
                String macAddress = getMacByInetAddress(inetAddress);
                macAddressList.add( macAddress );
            }
        }
        return macAddressList;
    }

    
    private static ListgetLocalAllInetAddress() throws Exception {
        Listresult = new ArrayList<>(4);
        for (Enumeration networkInterfaces = NetworkInterface.getNetworkInterfaces(); networkInterfaces.hasMoreElements(); ) {
            NetworkInterface iface = (NetworkInterface) networkInterfaces.nextElement();
            for (Enumeration inetAddresses = iface.getInetAddresses(); inetAddresses.hasMoreElements(); ) {
                InetAddress inetAddr = (InetAddress) inetAddresses.nextElement();
                if (!inetAddr.isLoopbackAddress()
                        && !inetAddr.isLinkLocalAddress() && !inetAddr.isMulticastAddress()) {
                    result.add(inetAddr);
                }
            }
        }
        return result;
    }

   
    private static String getMacByInetAddress(InetAddress inetAddr) {
        try {
            byte[] mac = NetworkInterface.getByInetAddress(inetAddr).getHardwareAddress();
            StringBuffer stringBuffer = new StringBuffer();

            for (int i = 0; i< mac.length; i++) {
                if (i != 0) {
                    stringBuffer.append("-");
                }

               
                String temp = Integer.toHexString(mac[i] & 0xff);
                if (temp.length() == 1) {
                    stringBuffer.append("0" + temp);
                } else {
                    stringBuffer.append(temp);
                }
            }
            return stringBuffer.toString().toUpperCase();
        } catch (SocketException e) {
            e.printStackTrace();
        }
        return null;
    }

    private static void printServerInfo() throws Exception {
        System.out.println( "server info:" );
        System.out.println( "macAddress list:" );
        String osName = System.getProperty("os.name").toLowerCase();
        
        ListmacAddressList = null;
        if (osName.startsWith("windows")) {
            macAddressList = getMacAddress4Windows();
        } else if (osName.startsWith("linux")) {
            macAddressList = getMacAddress4Linux();
        }else{
            macAddressList = getMacAddress4Linux();
        }
        if( macAddressList == null || macAddressList.size() == 0 ){
            return;
        }
        for( String macAddress:macAddressList ){
            System.out.println( "   " + macAddress );
        }
    }

    public static void main(String[] args) throws Exception {
        printServerInfo();
    }
}
javac PrintServerMacInfo.java
java PrintServerMacInfo

你是否還在尋找穩(wěn)定的海外服務(wù)器提供商?創(chuàng)新互聯(lián)www.cdcxhl.cn海外機(jī)房具備T級流量清洗系統(tǒng)配攻擊溯源,準(zhǔn)確流量調(diào)度確保服務(wù)器高可用性,企業(yè)級服務(wù)器適合批量采購,新人活動首月15元起,快前往官網(wǎng)查看詳情吧

讓客戶滿意是我們工作的目標(biāo),不斷超越客戶的期望值來自于我們對這個行業(yè)的熱愛。我們立志把好的技術(shù)通過有效、簡單的方式提供給客戶,將通過不懈努力成為客戶在信息化領(lǐng)域值得信任、有價值的長期合作伙伴,公司提供的服務(wù)項(xiàng)目有:主機(jī)域名、虛擬空間、營銷軟件、網(wǎng)站建設(shè)、郎溪網(wǎng)站維護(hù)、網(wǎng)站推廣。
當(dāng)前文章:java輸出服務(wù)器的mac地址-創(chuàng)新互聯(lián)
路徑分享:http://weahome.cn/article/csicpj.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部