當前位置: 首頁>>代碼示例>>Java>>正文


Java FileUtil.findFirstThatExist方法代碼示例

本文整理匯總了Java中com.intellij.openapi.util.io.FileUtil.findFirstThatExist方法的典型用法代碼示例。如果您正苦於以下問題:Java FileUtil.findFirstThatExist方法的具體用法?Java FileUtil.findFirstThatExist怎麽用?Java FileUtil.findFirstThatExist使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.intellij.openapi.util.io.FileUtil的用法示例。


在下文中一共展示了FileUtil.findFirstThatExist方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getExecutable

import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
@Nullable
private static File getExecutable() {
  String execPath = System.getProperty(PROPERTY_WATCHER_EXECUTABLE_PATH);
  if (execPath != null) return new File(execPath);

  String execName = getExecutableName(false);
  if (execName == null) return null;

  return FileUtil.findFirstThatExist(FileUtil.join(PathManager.getBinPath(), execName),
                                     FileUtil.join(PathManager.getHomePath(), "community", "bin", getExecutableName(true)),
                                     FileUtil.join(PathManager.getBinPath(), getExecutableName(true)));
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:13,代碼來源:NativeFileWatcherImpl.java

示例2: init

import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
private void init() {
  try {
    System.setProperty("log4j.defaultInitOverride", "true");

    File logXmlFile = FileUtil.findFirstThatExist(PathManager.getHomePath() + "/bin/log.xml",
                                                  PathManager.getHomePath() + "/community/bin/log.xml");
    if (logXmlFile == null) {
      throw new RuntimeException("log.xml file does not exist! Path: [ $home/bin/log.xml]");
    }

    String text = FileUtil.loadFile(logXmlFile);
    text = StringUtil.replace(text, SYSTEM_MACRO, StringUtil.replace(PathManager.getSystemPath(), "\\", "\\\\"));
    text = StringUtil.replace(text, APPLICATION_MACRO, StringUtil.replace(PathManager.getHomePath(), "\\", "\\\\"));
    text = StringUtil.replace(text, LOG_DIR_MACRO, StringUtil.replace(PathManager.getLogPath(), "\\", "\\\\"));

    File file = new File(PathManager.getLogPath());
    if (!file.mkdirs() && !file.exists()) {
      System.err.println("Cannot create log directory: " + file);
    }

    new DOMConfigurator().doConfigure(new StringReader(text), LogManager.getLoggerRepository());

    myInitialized = true;
  }
  catch (Exception e) {
    e.printStackTrace();
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:29,代碼來源:LoggerFactory.java

示例3: fromFile

import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
private static BuildNumber fromFile() {
  try {
    String home = PathManager.getHomePath();
    File buildTxtFile = FileUtil.findFirstThatExist(home + "/build.txt", home + "/Resources/build.txt", home + "/community/build.txt");
    if (buildTxtFile != null) {
      String text = FileUtil.loadFile(buildTxtFile).trim();
      return fromString(text);
    }
  }
  catch (IOException ignored) { }

  return fallback();
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:14,代碼來源:BuildNumber.java

示例4: getShellEnv

import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
private static Map<String, String> getShellEnv() throws Exception {
  String shell = System.getenv("SHELL");
  if (shell == null || !new File(shell).canExecute()) {
    throw new Exception("shell:" + shell);
  }

  File reader = FileUtil.findFirstThatExist(
    PathManager.getBinPath() + "/printenv.py",
    PathManager.getHomePath() + "/community/bin/mac/printenv.py",
    PathManager.getHomePath() + "/bin/mac/printenv.py"
  );
  if (reader == null) {
    throw new Exception("bin:" + PathManager.getBinPath());
  }

  File envFile = FileUtil.createTempFile("intellij-shell-env.", ".tmp", false);
  try {
    String[] command = {shell, "-l", "-i", "-c", ("'" + reader.getAbsolutePath() + "' '" + envFile.getAbsolutePath() + "'")};
    LOG.info("loading shell env: " + StringUtil.join(command, " "));

    Process process = Runtime.getRuntime().exec(command);
    int rv = waitAndTerminateAfter(process, SHELL_ENV_READING_TIMEOUT);

    String lines = FileUtil.loadFile(envFile);
    if (rv != 0 || lines.isEmpty()) {
      throw new Exception("rv:" + rv + " text:" + lines.length());
    }
    return parseEnv(lines);
  }
  finally {
    FileUtil.delete(envFile);
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:34,代碼來源:EnvironmentUtil.java

示例5: findFirstThatExist

import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
private static String findFirstThatExist(String... paths) {
  File sb = FileUtil.findFirstThatExist(paths);
  return sb == null ? null : sb.getPath();
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:5,代碼來源:SceneBuilderInfo.java


注:本文中的com.intellij.openapi.util.io.FileUtil.findFirstThatExist方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。