浪跡天涯
          web報表設計器....
          posts - 61,comments - 71,trackbacks - 0

          package com.paiao.ReadMac;

          import java.io.BufferedReader;
          import java.io.InputStreamReader;
          import java.io.IOException;

          public class ReadMac {
          ??? public ReadMac() {
          ??? }

          ??? public static String getMACAddress() {

          ??????? String address = "";
          ??????? String os = System.getProperty("os.name");
          ??????? if (os != null && os.startsWith("Windows")) {
          ??????????? try {
          ??????????????? String command = "cmd.exe /c ipconfig /all";
          ??????????????? Process p = Runtime.getRuntime().exec(command);
          ??????????????? BufferedReader br =
          ??????????????????????? new BufferedReader(
          ??????????????????????????????? new InputStreamReader(p.getInputStream()));
          ??????????????? String line;
          ??????????????? while ((line = br.readLine()) != null) {
          ??????????????????? if (line.indexOf("Physical Address") > 0) {
          ??????????????????????? int index = line.indexOf(":");
          ??????????????????????? index += 2;
          ??????????????????????? address = line.substring(index);
          ??????????????????????? break;
          ??????????????????? }
          ??????????????? }
          ??????????????? br.close();
          ??????????????? return address.trim();
          ??????????? } catch (IOException e) {}
          ??????? }
          ??????? return address;
          ??? }

          public static void main(String[] args) {
          ??? System.out.println("Mac:"+ReadMac.getMACAddress());
          }
          }

          posted on 2007-03-25 00:47 JJCEA 閱讀(484) 評論(0)  編輯  收藏 所屬分類: 學習日記
          主站蜘蛛池模板: 昌黎县| 漯河市| 阆中市| 宝山区| 东方市| 南通市| 武夷山市| 梅河口市| 九龙县| 休宁县| 师宗县| 乌兰察布市| 上栗县| 营山县| 拜城县| 探索| 伊宁县| 敦化市| 肇东市| 博罗县| 永城市| 枣庄市| 新建县| 东辽县| 温泉县| 乌恰县| 六盘水市| 大足县| 尚义县| 米脂县| 山东省| 博乐市| 成武县| 二手房| 资溪县| 安龙县| 达尔| 沁源县| 萍乡市| 天等县| 湄潭县|