本文整理匯總了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)));
}
示例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();
}
}
示例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();
}
示例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);
}
}
示例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();
}