예제 #1
0
  /**
   * <br>
   * Created on: 2013-8-21 上午10:59:29
   */
  private static void getMacAddress() {
    BufferedReader br = null;
    Process process = null;
    Pattern macPattern = null;
    Matcher macMatcher = null;

    try {

      if (Env.getPlatform() == Env.getOsWindows())
        process = Runtime.getRuntime().exec("cmd /c ipconfig /all");
      else if (Env.getPlatform() == Env.getOsUnix())
        process = Runtime.getRuntime().exec("ifconfig");

      br = new BufferedReader(new InputStreamReader(process.getInputStream()));

      String line = null;

      macPattern = Pattern.compile("([0-9A-Fa-f]{2})(-[0-9A-Fa-f]{2}){5}");
      boolean result = false;

      while ((line = br.readLine()) != null) {
        if (DataTools.isEmpty(line)) continue;
        macMatcher = macPattern.matcher(line);
        result = macMatcher.find();
        if (result) list.add(macMatcher.group(0));
      }
      br.close();
      br = null;
      macMatcher = null;
      macPattern = null;
    } catch (IOException e) {
    } finally {
      try {
        if (!DataTools.isEmpty(br)) {
          br.close();
          br = null;
        }
        macMatcher = null;
        macPattern = null;
      } catch (IOException e) {
      } finally {
        br = null;
        macMatcher = null;
        macPattern = null;
      }
    }
  }
예제 #2
0
  /**
   * <br>
   * Created on: Dec 1, 2012 2:46:13 PM
   *
   * @param fileName
   * @return
   */
  public static String replaceProHome(String fileName) {

    String basedir = System.getProperty("basedir");

    if (DataTools.isEmpty(basedir)) {
      String proHome = "\\$PRO_HOME/";
      return fileName.replaceAll(proHome, "");
    }

    if (Env.getPlatform() == Env.getOsWindows()) basedir = replaceWinSepaToUnix(basedir);

    return fileName.replaceAll("\\$PRO_HOME", basedir);
  }