当前位置: 首页>>代码示例>>Java>>正文


Java VfsUtil.loadText方法代码示例

本文整理汇总了Java中com.intellij.openapi.vfs.VfsUtil.loadText方法的典型用法代码示例。如果您正苦于以下问题:Java VfsUtil.loadText方法的具体用法?Java VfsUtil.loadText怎么用?Java VfsUtil.loadText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.openapi.vfs.VfsUtil的用法示例。


在下文中一共展示了VfsUtil.loadText方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getReaderByUrl

import com.intellij.openapi.vfs.VfsUtil; //导入方法依赖的package包/类
@Nullable
public static Reader getReaderByUrl(final String surl, final HttpConfigurable httpConfigurable, final ProgressIndicator pi) throws IOException {
    if (surl.startsWith(JAR_PROTOCOL)) {
        VirtualFile file = VirtualFileManager.getInstance().findFileByUrl(BrowserUtil.getDocURL(surl));

        if (file == null) {
            return null;
        }

        return new StringReader(VfsUtil.loadText(file));
    }

    URL url = BrowserUtil.getURL(surl);
    if (url == null) {
        return null;
    }
    httpConfigurable.prepareURL(url.toString());
    final URLConnection urlConnection = url.openConnection();
    final String contentEncoding = urlConnection.getContentEncoding();
    final InputStream inputStream =
            pi != null ? UrlConnectionUtil.getConnectionInputStreamWithException(urlConnection, pi) : urlConnection.getInputStream();
    //noinspection IOResourceOpenedButNotSafelyClosed
    return contentEncoding != null ? new InputStreamReader(inputStream, contentEncoding) : new InputStreamReader(inputStream);
}
 
开发者ID:internetisalie,项目名称:lua-for-idea,代码行数:25,代码来源:UrlUtil.java

示例2: configureByFile

import com.intellij.openapi.vfs.VfsUtil; //导入方法依赖的package包/类
/**
 * Like <a href="#configureByFileText(String, String, String)">configureByFileText</a>, but with a file to be read.
 * @param filePath file to read and parse
 * @param markerRegexp regexp for markers
 * @return a mapping of markers to PSI elements
 * @throws Exception
 */
protected Map<String, PsiElement> configureByFile(@TestDataFile @NonNls String filePath, @NonNls String markerRegexp) {
  final String fullPath = getTestDataPath() + filePath;
  final VirtualFile vFile = getVirtualFileByName(fullPath);
  assertNotNull("file " + fullPath + " not found", vFile);

  final String text;
  try {
    text = VfsUtil.loadText(vFile);
  }
  catch (IOException e) {
    throw new RuntimeException(e);
  }
  String fileText = StringUtil.convertLineSeparators(text, "\n");

  final String fileName = vFile.getName();

  return configureByFileText(fileText, fileName, markerRegexp);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:LightMarkedTestCase.java

示例3: read

import com.intellij.openapi.vfs.VfsUtil; //导入方法依赖的package包/类
@Nullable
public static Element read(final VirtualFile file, @Nullable final ErrorHandler handler) {
  String text;

  AccessToken accessToken = ApplicationManager.getApplication().acquireReadActionLock();
  try {
    if (!file.isValid()) return null;

    try {
      text = VfsUtil.loadText(file);
    }
    catch (IOException e) {
      if (handler != null) handler.onReadError(e);
      return null;
    }
  }
  finally {
    accessToken.finish();
  }

  return doRead(text, handler);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:MavenJDOMUtil.java

示例4: calcPropertyValue

import com.intellij.openapi.vfs.VfsUtil; //导入方法依赖的package包/类
protected String calcPropertyValue(String propertyName) {
  String text = myCachedText;
  if (text != null) {
    return text; 
  }
  final PsiFileSystemItem file = getSrcFile().getValue();
  if (!(file instanceof PsiFile)) {
    return "";
  }
  final VirtualFile vFile = ((PsiFile)file).getOriginalFile().getVirtualFile();
  if (vFile == null) {
    return "";
  }
  try {
    text = VfsUtil.loadText(vFile);
    myCachedText = text;
  }
  catch (IOException e) {
    LOG.info(e);
    text = "";
  }
  return text;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:AntDomLoadFileTask.java

示例5: configureByFileWithMarker

import com.intellij.openapi.vfs.VfsUtil; //导入方法依赖的package包/类
protected PsiElement configureByFileWithMarker(String filePath, String marker) throws Exception{
  final VirtualFile vFile = LocalFileSystem.getInstance().findFileByPath(filePath.replace(File.separatorChar, '/'));
  assertNotNull("file " + filePath + " not found", vFile);

  String fileText = VfsUtil.loadText(vFile);
  fileText = StringUtil.convertLineSeparators(fileText);

  int offset = fileText.indexOf(marker);
  assertTrue(offset >= 0);
  fileText = fileText.substring(0, offset) + fileText.substring(offset + marker.length());

  myFile = createFile(vFile.getName(), fileText);

  return myFile.findElementAt(offset);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:PsiTestCase.java

示例6: getInstalledPluginNameByPath

import com.intellij.openapi.vfs.VfsUtil; //导入方法依赖的package包/类
@Override
public String getInstalledPluginNameByPath(Project project, @NotNull VirtualFile pluginPath) {
  String nameFromPluginXml = super.getInstalledPluginNameByPath(project, pluginPath);
  if (nameFromPluginXml != null) {
    return nameFromPluginXml;
  }

  VirtualFile pluginJson = pluginPath.findChild("plugin.json");
  if (pluginJson != null) {
    String pluginAndVersion = pluginPath.getName(); // pluginName-version

    TIntArrayList separatorIndexes = new TIntArrayList();
    int start = -1;
    while (true) {
      start = pluginAndVersion.indexOf('-', start + 1);
      if (start == -1) break;
      separatorIndexes.add(start);
    }

    if (separatorIndexes.size() == 1) {
      return pluginAndVersion.substring(0, separatorIndexes.get(0));
    }

    if (!separatorIndexes.isEmpty()) {
      String json;
      try {
        json = VfsUtil.loadText(pluginJson);
      }
      catch (IOException e) {
        return null;
      }

      for (int i = 0; i < separatorIndexes.size(); i++) {
        int idx = separatorIndexes.get(i);
        String name = pluginAndVersion.substring(0, idx);
        String version = pluginAndVersion.substring(idx + 1);

        if (hasValue(PLUGIN_NAME_JSON_PATTERN, json, name) && hasValue(PLUGIN_VERSION_JSON_PATTERN, json, version)) {
          return name;
        }
      }
    }
  }

  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:47,代码来源:GriffonFramework.java


注:本文中的com.intellij.openapi.vfs.VfsUtil.loadText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。