Java,J2EE,Weblogic,Oracle

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

          java執行命令,得到Mac地址

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

            System.out.println("操作系統:"+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("網卡Mac地址:"+address);

           }

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


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


          網站導航:
           
          主站蜘蛛池模板: 宿迁市| 佳木斯市| 奉化市| 淳化县| 洞口县| 密山市| 浦北县| 德钦县| 柳林县| 浮梁县| 郸城县| 长寿区| 延长县| 庆阳市| 贡嘎县| 孝感市| 闽清县| 临朐县| 五常市| 和硕县| 贵定县| 平乐县| 文水县| 息烽县| 阜城县| 榕江县| 响水县| 陕西省| 大安市| 房产| 建始县| 托里县| 长海县| 砀山县| 梁河县| 邯郸市| 星子县| 大埔县| 新田县| 花垣县| 揭阳市|