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