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


Java FileUtil.loadFileText方法代碼示例

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


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

示例1: readFileAsString

import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
public static String readFileAsString(String filePath) {
 String content;
 try {
   content = new String(FileUtil.loadFileText(new File(filePath)));
   content = StringUtil.replace(content, "\r", "");
 } catch (IOException e) {
   throw new RuntimeException(e);
 }
 Assert.assertNotNull(content);
 return content;
}
 
開發者ID:internetisalie,項目名稱:lua-for-idea,代碼行數:12,代碼來源:TestUtils.java

示例2: load

import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
private String load() {
  File configFile = getConfigFile();
  if (configFile.exists()) {
    try {
      return new String(FileUtil.loadFileText(configFile));
    }
    catch (IOException e) {
      LOG.info("Cannot load configuration of " + myTarget);
    }
  }
  return "";
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:13,代碼來源:BuildTargetConfiguration.java

示例3: scanSourceFile

import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
private void scanSourceFile(File file, final Set<String> usedPackages) {
  myProgress.setText2(file.getName());
  try {
    final char[] chars = FileUtil.loadFileText(file);
    scanSourceFileForImportedPackages(StringFactory.createShared(chars), new Consumer<String>() {
      public void consume(final String s) {
        usedPackages.add(myInterner.intern(s));
      }
    });
  }
  catch (IOException e) {
    LOG.info(e);
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:15,代碼來源:ModuleInsight.java

示例4: loadPatches

import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
private static List<TextFilePatch> loadPatches(Project project,
                                               final String patchPath,
                                               CommitContext commitContext,
                                               boolean loadContent) throws IOException, PatchSyntaxException {
  char[] text = FileUtil.loadFileText(new File(patchPath), CharsetToolkit.UTF8);
  PatchReader reader = new PatchReader(new CharArrayCharSequence(text), loadContent);
  final List<TextFilePatch> textFilePatches = reader.readAllPatches();
  final TransparentlyFailedValueI<Map<String, Map<String, CharSequence>>, PatchSyntaxException> additionalInfo = reader.getAdditionalInfo(
    null);
  ApplyPatchDefaultExecutor.applyAdditionalInfoBefore(project, additionalInfo, commitContext);
  return textFilePatches;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:13,代碼來源:ShelveChangesManager.java

示例5: getRevisionsForDiff

import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
/**
 * @return The revision range which will be used to find merge diff (merge may be just finished, or in progress)
 * or null in case of error or inconsistency.
 */
@Nullable
public String getRevisionsForDiff() throws VcsException {
  String root = myRoot.getPath();
  GitRevisionNumber currentHead = GitRevisionNumber.resolve(myProject, myRoot, "HEAD");
  if (currentHead.equals(myStart)) {
    // The head has not advanced. This means that this is a merge that did not commit.
    // This could be caused by --no-commit option or by failed two-head merge. The MERGE_HEAD
    // should be available. In case of --no-commit option, the MERGE_HEAD might contain
    // multiple heads separated by newline. The changes are collected separately for each head
    // and they are merged using TreeSet class (that also sorts the changes).
    File mergeHeadsFile = new File(root, GitRepositoryFiles.GIT_MERGE_HEAD);
    try {
      if (mergeHeadsFile.exists()) {
        String mergeHeads = new String(FileUtil.loadFileText(mergeHeadsFile, CharsetToolkit.UTF8));
        for (StringScanner s = new StringScanner(mergeHeads); s.hasMoreData();) {
          String head = s.line();
          if (head.length() == 0) {
            continue;
          }
          // note that "..." cause the diff to start from common parent between head and merge head
          return myStart.getRev() + "..." + head;
        }
      }
    } catch (IOException e) {
      //noinspection ThrowableInstanceNeverThrown
      throw new VcsException("Unable to read the file " + mergeHeadsFile + ": " + e.getMessage(), e);
    }
  } else {
    // Otherwise this is a merge that did created a commit. And because of this the incoming changes
    // are diffs between old head and new head. The commit could have been multihead commit,
    // and the expression below considers it as well.
    return myStart.getRev() + "..HEAD";
  }
  return null;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:40,代碼來源:MergeChangeCollector.java

示例6: loadResult

import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
protected static String loadResult(VirtualFile pomFile, String relativePath) throws IOException {
  File file = new File(pomFile.getParent().getPath(), relativePath);
  assertTrue("file not found: " + relativePath, file.exists());
  return new String(FileUtil.loadFileText(file));
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:6,代碼來源:MavenCompilingTestCase.java


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