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


Java FileUtil.loadFile方法代碼示例

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


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

示例1: doStepOptionsCreationTest

import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
private static StepicWrappers.StepOptions doStepOptionsCreationTest(String fileName) throws IOException {
  String responseString =
    FileUtil.loadFile(new File(getTestDataPath(), fileName));
  StepicWrappers.StepSource stepSource =
    EduStepicClient.deserializeStepicResponse(StepicWrappers.StepContainer.class, responseString).steps.get(0);
  StepicWrappers.StepOptions options = stepSource.block.options;
  List<TaskFile> files = options.files;
  assertTrue("Wrong number of task files", files.size() == 1);
  List<AnswerPlaceholder> placeholders = files.get(0).getAnswerPlaceholders();
  assertTrue("Wrong number of placeholders", placeholders.size() == 1);
  Map<Integer, AnswerPlaceholderSubtaskInfo> infos = placeholders.get(0).getSubtaskInfos();
  assertNotNull(infos);
  assertEquals(Collections.singletonList("Type your name here."), infos.get(0).getHints());
  assertEquals("Liana", infos.get(0).getPossibleAnswer());
  return options;
}
 
開發者ID:medvector,項目名稱:educational-plugin,代碼行數:17,代碼來源:StudyStepicFormatTest.java

示例2: initLoggers

import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
public static void initLoggers() {
  if (!SystemProperties.getBooleanProperty(GlobalOptions.USE_DEFAULT_FILE_LOGGING_OPTION, true)) {
    return;
  }

  try {
    final String logDir = System.getProperty(GlobalOptions.LOG_DIR_OPTION, null);
    final File configFile = logDir != null? new File(logDir, LOG_CONFIG_FILE_NAME) : new File(LOG_CONFIG_FILE_NAME);
    ensureLogConfigExists(configFile);
    String text = FileUtil.loadFile(configFile);
    final String logFile = logDir != null? new File(logDir, LOG_FILE_NAME).getAbsolutePath() : LOG_FILE_NAME;
    text = StringUtil.replace(text, LOG_FILE_MACRO, StringUtil.replace(logFile, "\\", "\\\\"));
    PropertyConfigurator.configure(new ByteArrayInputStream(text.getBytes("UTF-8")));
  }
  catch (IOException e) {
    //noinspection UseOfSystemOutOrSystemErr
    System.err.println("Failed to configure logging: ");
    //noinspection UseOfSystemOutOrSystemErr
    e.printStackTrace(System.err);
  }

  Logger.setFactory(MyLoggerFactory.class);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:24,代碼來源:LogSetup.java

示例3: startProcess

import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
@NotNull
@Override
protected Process startProcess(@NotNull List<String> commands) throws IOException {
  try {
    return startProcessWithPty(commands, myConsoleMode);
  }
  catch (Throwable e) {
    File logFile = getPtyLogFile();
    if (ApplicationManager.getApplication().isEAP() && logFile.exists()) {
      String logContent;
      try {
        logContent = FileUtil.loadFile(logFile);
      } catch (Exception ignore) {
        logContent = "Unable to retrieve log";
      }

      LOG.error("Couldn't run process with PTY", e, logContent);
    }
    else {
      LOG.error("Couldn't run process with PTY", e);
    }
  }

  return super.startProcess(commands);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:26,代碼來源:PtyCommandLine.java

示例4: readRemoteResults

import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
private static Set<GitRemote> readRemoteResults(File resultFile) throws IOException {
  String content = FileUtil.loadFile(resultFile);
  Set<GitRemote> remotes = new HashSet<GitRemote>();
  List<String> remStrings = StringUtil.split(content, "REMOTE");
  for (String remString : remStrings) {
    if (StringUtil.isEmptyOrSpaces(remString)) {
      continue;
    }
    String[] info = StringUtil.splitByLines(remString.trim());
    String name = info[0];
    List<String> urls = getSpaceSeparatedStrings(info[1]);
    Collection<String> pushUrls = getSpaceSeparatedStrings(info[2]);
    List<String> fetchSpec = getSpaceSeparatedStrings(info[3]);
    List<String> pushSpec = getSpaceSeparatedStrings(info[4]);
    GitRemote remote = new GitRemote(name, urls, pushUrls, fetchSpec, pushSpec);
    remotes.add(remote);
  }
  return remotes;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:20,代碼來源:GitConfigTest.java

示例5: streamInfo

import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
private static Object streamInfo(InputStream stream) throws IOException {
  if (stream instanceof BufferedInputStream) {
    InputStream in = ReflectionUtil.getField(stream.getClass(), stream, InputStream.class, "in");
    byte[] buf = ReflectionUtil.getField(stream.getClass(), stream, byte[].class, "buf");
    int count = ReflectionUtil.getField(stream.getClass(), stream, int.class, "count");
    int pos = ReflectionUtil.getField(stream.getClass(), stream, int.class, "pos");

    return "BufferedInputStream(buf="+(buf == null ? null : Arrays.toString(Arrays.copyOf(buf, count))) + ", count="+count+ ", pos="+pos+", in="+streamInfo(in)+")";
  }
  if (stream instanceof FileInputStream) {
    String path = ReflectionUtil.getField(stream.getClass(), stream, String.class, "path");
    FileChannel channel = ReflectionUtil.getField(stream.getClass(), stream, FileChannel.class, "channel");
    boolean closed = ReflectionUtil.getField(stream.getClass(), stream, boolean.class, "closed");
    int available = stream.available();
    File file = new File(path);
    return "FileInputStream(path="+path+ ", available="+available+ ", closed="+closed+ ", channel="+channel+", channel.size="+(channel==null?null:channel.size())+", file.exists=" + file.exists()+", file.content='"+FileUtil.loadFile(file)+"')";
  }
  return stream;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:20,代碼來源:FileTypeManagerImpl.java

示例6: testAvailableCourses

import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
@Test
public void testAvailableCourses() throws IOException {
  String responseString = FileUtil.loadFile(new File(getTestDataPath(), "courses.json"));
  StepicWrappers.CoursesContainer container =
    EduStepicClient.deserializeStepicResponse(StepicWrappers.CoursesContainer.class, responseString);
  assertNotNull(container.courses);
  assertTrue("Incorrect number of courses", container.courses.size() == 4);
}
 
開發者ID:medvector,項目名稱:educational-plugin,代碼行數:9,代碼來源:StudyStepicFormatTest.java

示例7: load

import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
@NotNull
public List<GitRebaseEntry> load() throws IOException, NoopException {
  String encoding = GitConfigUtil.getLogEncoding(myProject, myRoot);
  List<GitRebaseEntry> entries = ContainerUtil.newArrayList();
  final StringScanner s = new StringScanner(FileUtil.loadFile(new File(myFile), encoding));
  boolean noop = false;
  while (s.hasMoreData()) {
    if (s.isEol() || s.startsWith('#')) {
      s.nextLine();
      continue;
    }
    if (s.startsWith("noop")) {
      noop = true;
      s.nextLine();
      continue;
    }
    String action = s.spaceToken();
    String hash = s.spaceToken();
    String comment = s.line();

    entries.add(new GitRebaseEntry(action, hash, comment));
  }
  if (noop && entries.isEmpty()) {
    throw new NoopException();
  }
  return entries;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:28,代碼來源:GitInteractiveRebaseFile.java

示例8: addTemplateFromFile

import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
private void addTemplateFromFile(String fileName, File file) {
  Pair<String,String> nameExt = decodeFileName(fileName);
  final String extension = nameExt.second;
  final String templateQName = nameExt.first;
  if (templateQName.length() == 0) {
    return;
  }
  try {
    final String text = FileUtil.loadFile(file, CharsetToolkit.UTF8_CHARSET);
    addTemplate(templateQName, extension).setText(text);
  }
  catch (IOException e) {
    LOG.error(e);
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:16,代碼來源:FTManager.java

示例9: testPerformance

import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
public void testPerformance() throws Exception {
  final String path = PathManagerEx.getTestDataPath() + "/psi/stub/StubPerformanceTest.java";
  String text = FileUtil.loadFile(new File(path));
  final PsiJavaFile file = (PsiJavaFile)createLightFile("test.java", text);

  PlatformTestUtil.startPerformanceTest("Source file size: " + text.length(), 2000, new ThrowableRunnable() {
    @Override
    public void run() throws Exception {
      NEW_BUILDER.buildStubTree(file);
    }
  }).cpuBound().assertTiming();
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:13,代碼來源:continuationIndents_DoNotCount.java

示例10: testPackageInfo

import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
public void testPackageInfo() throws Exception {
  final String path = JavaTestUtil.getJavaTestDataPath() + "/codeInsight/javadocIG/";
  final String packageInfo = path + getTestName(true);
  PsiTestUtil.createTestProjectStructure(myProject, myModule, path, myFilesToDelete);
  final String info =
    new JavaDocInfoGenerator(getProject(), JavaPsiFacade.getInstance(getProject()).findPackage(getTestName(true))).generateDocInfo(null);
  String htmlText = FileUtil.loadFile(new File(packageInfo + File.separator + "packageInfo.html"));
  assertNotNull(info);
  assertEquals(StringUtil.convertLineSeparators(htmlText.trim()), replaceEnvironmentDependentContent(info));
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:11,代碼來源:JavaDocInfoGeneratorTest.java

示例11: testPackageInfoFromComment

import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
public void testPackageInfoFromComment() throws Exception {
  final String rootPath = getTestDataPath() + "/codeInsight/javadocIG/";
  VirtualFile root = PsiTestUtil.createTestProjectStructure(myProject, myModule, rootPath, myFilesToDelete);
  VirtualFile piFile = root.findFileByRelativePath("packageInfoFromComment/package-info.java");
  assertNotNull(piFile);
  PsiFile psiFile = PsiManager.getInstance(myProject).findFile(piFile);
  assertNotNull(psiFile);
  final String info = JavaExternalDocumentationTest.getDocumentationText(psiFile, psiFile.getText().indexOf("some"));
  String htmlText = FileUtil.loadFile(new File(rootPath + getTestName(true) + File.separator + "packageInfo.html"));
  assertEquals(StringUtil.convertLineSeparators(htmlText.trim()), replaceEnvironmentDependentContent(info));
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:12,代碼來源:JavaDocInfoGeneratorTest.java

示例12: testDeadlock

import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
public void testDeadlock() throws Exception {
  File file = new File(getTestDataPath() + "deadlock.txt");
  String s = FileUtil.loadFile(file);
  showText(s);
  assertIcon("killProcess.png", myContent.getIcon());
  assertEquals("<Deadlock>", myContent.getDisplayName());
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:8,代碼來源:UnscrambleDialogTest.java

示例13: readBranches

import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
@NotNull
private static Collection<Branch> readBranches(@NotNull File resultDir, boolean local) throws IOException {
  String content = FileUtil.loadFile(new File(resultDir, local ? "local-branches.txt" : "remote-branches.txt"));
  Collection<Branch> branches = ContainerUtil.newArrayList();
  for (String line : StringUtil.splitByLines(content)) {
    branches.add(readBranchFromLine(line));
  }
  return branches;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:10,代碼來源:GitRepositoryReaderTest.java

示例14: patchAndMarkGeneratedFile

import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
private static void patchAndMarkGeneratedFile(@NotNull AndroidFacet facet,
                                              @NotNull AndroidAutogeneratorMode mode,
                                              @NotNull VirtualFile vFile) throws IOException {
  final File file = new File(vFile.getPath());
  final String fileText = FileUtil.loadFile(file);
  FileUtil.writeToFile(file, AndroidCommonUtils.AUTOGENERATED_JAVA_FILE_HEADER + "\n\n" + fileText);
  facet.markFileAutogenerated(mode, vFile);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:9,代碼來源:AndroidAutogenerator.java

示例15: load

import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
public void load(File file, String encoding) throws IOException{
  String propText = FileUtil.loadFile(file, encoding);
  propText = StringUtil.convertLineSeparators(propText);
  StringTokenizer stringTokenizer = new StringTokenizer(propText, "\n");
  while (stringTokenizer.hasMoreElements()){
    String line = stringTokenizer.nextElement();
    int i = line.indexOf('=');
    String propName = i == -1 ? line : line.substring(0,i);
    String propValue = i == -1 ? "" : line.substring(i+1);
    setProperty(propName, propValue);
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:13,代碼來源:EncodingAwareProperties.java


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