浪跡天涯
          web報(bào)表設(shè)計(jì)器....
          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) 評(píng)論(0)  編輯  收藏 所屬分類: 學(xué)習(xí)日記
          主站蜘蛛池模板: 曲周县| 长岛县| 杭锦旗| 温州市| 仪陇县| 苍山县| 大田县| 安康市| 诏安县| 晴隆县| 重庆市| 霍林郭勒市| 永靖县| 石屏县| 永平县| 文昌市| 唐河县| 武义县| 津南区| 成都市| 社旗县| 兴国县| 额济纳旗| 柯坪县| 永州市| 本溪市| 龙里县| 章丘市| 白玉县| 集贤县| 陇川县| 淳安县| 同心县| 浦东新区| 施甸县| 吉隆县| 镇坪县| 绥德县| 都安| 伊川县| 理塘县|