Java 获取Mac地址 MD5后 可用于licence

  public static void getLisence(){
    System.out.println(System.getProperty("os.name"));
     try {
   Process process = Runtime.getRuntime().exec("ipconfig /all");
   BufferedReader bufferReader = new BufferedReader (new  InputStreamReader(process.getInputStream()));
   int index=0;
   String line="";
   while((line = bufferReader.readLine())!=null){
   
   index = line.indexOf("Physical Address");
   if(index>=0){
    index = line.indexOf(":");
    if(index>=0){
     line = line.substring((index+1)).trim();
     break;
    }
   }
   }
    System.out.println(line);
  } catch (IOException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  }

你可能感兴趣的:(java,OS)