Java獲取mac地址的方法
更新時(shí)間:2015年07月24日 11:44:01 作者:fzhlee
這篇文章主要介紹了Java獲取mac地址的方法,涉及java針對(duì)系統(tǒng)硬件及IO操作的相關(guān)技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下
本文實(shí)例講述了Java獲取mac地址的方法。分享給大家供大家參考。具體如下:
/*
* GetMacAddress .java
*
* description:get Mac addreess
*
* @author hadeslee
*
* Created on 2007-9-27, 9:11:15
*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package test2;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/**
*
*/
public class GetMacAddress {
public static String getMACAddress() {
String address = "";
String os = System.getProperty("os.name");
System.out.println(os);
if (os != null && os.startsWith("Windows")) {
try {
ProcessBuilder pb = new ProcessBuilder("ipconfig", "/all");
Process p = pb.start();
BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line;
while ((line = br.readLine()) != null) {
if (line.indexOf("Physical Address") != -1) {
int index = line.indexOf(":");
address = line.substring(index+1);
break;
}
}
br.close();
return address.trim();
} catch (IOException e) {
}
}
return address;
}
public static void main(String[] args) {
System.out.println("" + Test.getMACAddress());
}
}
希望本文所述對(duì)大家的java程序設(shè)計(jì)有所幫助。
您可能感興趣的文章:
- JAVA獲取本地MAC地址的方法
- JAVA如何獲取客戶端IP地址和MAC地址
- java根據(jù)本地IP獲取mac地址的方法
- java 獲取用戶的MAC地址多種方法實(shí)例詳解
- java 獲取mac地址的兩種方法(推薦)
- Java 獲取本機(jī)的IP與MAC地址實(shí)現(xiàn)詳解
- java編程實(shí)現(xiàn)獲取服務(wù)器IP地址及MAC地址的方法
- Java編程實(shí)現(xiàn)遍歷兩個(gè)MAC地址之間所有MAC的方法
- java實(shí)現(xiàn)獲取用戶的MAC地址
- java通過(guò)ip獲取客戶端Mac地址的小例子
- 詳解Java如何跨平臺(tái)獲取MAC地址
相關(guān)文章
springboot使用hibernate validation對(duì)參數(shù)校驗(yàn)的實(shí)現(xiàn)方法
這篇文章主要介紹了spring-boot 使用hibernate validation對(duì)參數(shù)進(jìn)行優(yōu)雅的校驗(yàn),本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-12-12
SpringCloud創(chuàng)建多模塊項(xiàng)目的實(shí)現(xiàn)示例
,Spring Cloud作為一個(gè)強(qiáng)大的微服務(wù)框架,提供了豐富的功能和組件,本文主要介紹了SpringCloud創(chuàng)建多模塊項(xiàng)目的實(shí)現(xiàn)示例,具有一定的參考價(jià)值,感興趣的可以了解一下2024-02-02
注冊(cè)中心配置了spring?security后客戶端啟動(dòng)報(bào)錯(cuò)
這篇文章主要為大家介紹了注冊(cè)中心配置了spring?security后客戶端啟動(dòng)報(bào)錯(cuò)問(wèn)題解決,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-07-07

