Java,J2EE,Weblogic,Oracle

          java項目隨筆
          隨筆 - 90, 文章 - 6, 評論 - 61, 引用 - 0
          數(shù)據(jù)加載中……

          java執(zhí)行命令,得到Mac地址

          public static void main(String[] args) {
            String os = System.getProperty("os.name");

            System.out.println("操作系統(tǒng):"+os);
            
            String address = "";
            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();              
                      } catch (Exception e) {}
                  }
            
            System.out.println("網(wǎng)卡Mac地址:"+address);

           }

          posted on 2007-09-06 10:41 龔椿深 閱讀(590) 評論(0)  編輯  收藏


          只有注冊用戶登錄后才能發(fā)表評論。


          網(wǎng)站導(dǎo)航:
           
          主站蜘蛛池模板: 阳高县| 辽阳市| 永平县| 滨海县| 尉犁县| 海南省| 平乡县| 沁阳市| 宁明县| 长阳| 彭阳县| 井冈山市| 栾川县| 从化市| 吴忠市| 祥云县| 广元市| 威海市| 呼玛县| 舟山市| 沛县| 滨海县| 竹北市| 漯河市| 桐城市| 张掖市| 德庆县| 兰西县| 湛江市| 深州市| 泸定县| 本溪| 宜黄县| 雷州市| 中宁县| 沽源县| 沾化县| 广饶县| 湘潭县| 马关县| 佛坪县|