Java Code Examples for com.intellij.openapi.util.io.FileUtil#loadFileText()
The following examples show how to use
com.intellij.openapi.util.io.FileUtil#loadFileText() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestUtils.java From BashSupport with Apache License 2.0 | 5 votes |
public static List<String> readInput(String filePath) throws IOException { String content = new String(FileUtil.loadFileText(new File(filePath))); Assert.assertNotNull(content); List<String> input = new ArrayList<String>(); int separatorIndex; content = StringUtil.replace(content, "\r", ""); // for MACs // Adding input before ----- while ((separatorIndex = content.indexOf("-----")) >= 0) { input.add(content.substring(0, separatorIndex - 1)); content = content.substring(separatorIndex); while (StringUtil.startsWithChar(content, '-')) { content = content.substring(1); } if (StringUtil.startsWithChar(content, '\n')) { content = content.substring(1); } } // Result - after ----- if (content.endsWith("\n")) { content = content.substring(0, content.length() - 1); } input.add(content); Assert.assertTrue("No data found in source file", input.size() > 0); Assert.assertNotNull("Test output points to null", input.size() > 1); return input; }
Example 2
Source File: ShelveChangesManager.java From consulo with Apache License 2.0 | 5 votes |
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.readTextPatches(); ApplyPatchDefaultExecutor.applyAdditionalInfoBefore(project, reader.getAdditionalInfo(null), commitContext); return textFilePatches; }