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


Java URLUtil类代码示例

本文整理汇总了Java中com.intellij.util.io.URLUtil的典型用法代码示例。如果您正苦于以下问题:Java URLUtil类的具体用法?Java URLUtil怎么用?Java URLUtil使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: toUri

import com.intellij.util.io.URLUtil; //导入依赖的package包/类
/**
 * @return correct URL, must be used only for external communication
 */
@NotNull
public static URI toUri(@NotNull VirtualFile file) {
  String path = file.getPath();
  try {
    String protocol = file.getFileSystem().getProtocol();
    if (file.isInLocalFileSystem()) {
      if (SystemInfo.isWindows && path.charAt(0) != '/') {
        path = '/' + path;
      }
      return new URI(protocol, "", path, null, null);
    }
    if (URLUtil.HTTP_PROTOCOL.equals(protocol)) {
      return new URI(URLUtil.HTTP_PROTOCOL + URLUtil.SCHEME_SEPARATOR + path);
    }
    return new URI(protocol, path, null);
  }
  catch (URISyntaxException e) {
    throw new IllegalArgumentException(e);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:VfsUtil.java

示例2: toDecodedForm

import com.intellij.util.io.URLUtil; //导入依赖的package包/类
@Override
public String toDecodedForm() {
  StringBuilder builder = new StringBuilder();
  if (scheme != null) {
    builder.append(scheme);
    if (authority == null) {
      builder.append(':');
    }
    else {
      builder.append(URLUtil.SCHEME_SEPARATOR);
    }

    if (authority != null) {
      builder.append(authority);
    }
  }
  builder.append(getPath());
  if (parameters != null) {
    builder.append(parameters);
  }
  return builder.toString();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:UrlImpl.java

示例3: applyFilter

import com.intellij.util.io.URLUtil; //导入依赖的package包/类
@Nullable
@Override
public Result applyFilter(String line, int entireLength) {
  int textStartOffset = entireLength - line.length();
  Matcher m = URLUtil.URL_PATTERN.matcher(line);
  ResultItem item = null;
  List<ResultItem> items = null;
  while (m.find()) {
    if (item == null) {
      item = new ResultItem(textStartOffset + m.start(), textStartOffset + m.end(), buildHyperlinkInfo(m.group()));
    } else {
      if (items == null) {
        items = new ArrayList<ResultItem>(2);
        items.add(item);
      }
      items.add(new ResultItem(textStartOffset + m.start(), textStartOffset + m.end(), buildHyperlinkInfo(m.group())));
    }
  }
  return items != null ? new Result(items)
                       : item != null ? new Result(item.getHighlightStartOffset(), item.getHighlightEndOffset(), item.getHyperlinkInfo())
                                      : null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:UrlFilter.java

示例4: loadText

import com.intellij.util.io.URLUtil; //导入依赖的package包/类
@NotNull
public static String loadText(@NotNull URL url) throws IOException {
  InputStream inputStream = new BufferedInputStream(URLUtil.openStream(url));

  InputStreamReader reader = new InputStreamReader(inputStream, CharsetToolkit.UTF8_CHARSET);
  try {
    StringBuilder text = new StringBuilder();
    char[] buf = new char[5000];
    while (reader.ready()) {
      final int length = reader.read(buf);
      if (length == -1) break;
      text.append(buf, 0, length);
    }
    return text.toString();
  }
  finally {
    reader.close();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:ResourceUtil.java

示例5: initLoaders

import com.intellij.util.io.URLUtil; //导入依赖的package包/类
/**
 * Used in com.intellij.openapi.projectRoots.JdkUtil#isClassPathJarEnabled(List, String)
 * as a condition that UrlClassLoader supports classpath jars. Please modify it accordingly.
 */
private void initLoaders(final URL url, boolean lastOne, int index) throws IOException {
  String path;

  if (myAcceptUnescapedUrls) {
    path = url.getFile();
  }
  else {
    try {
      path = url.toURI().getSchemeSpecificPart();
    }
    catch (URISyntaxException e) {
      Logger.getInstance(ClassPath.class).error("url: " + url, e);
      path = url.getFile();
    }
  }

  Loader loader = null;
  if (path != null && URLUtil.FILE_PROTOCOL.equals(url.getProtocol())) {
    loader = createLoader(url, index, new File(path), true);
  }

  if (loader != null) {
    initLoader(url, lastOne, loader);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:30,代码来源:ClassPath.java

示例6: copyResourceToFile

import com.intellij.util.io.URLUtil; //导入依赖的package包/类
private static boolean copyResourceToFile(@NotNull URL url, @NotNull File file, @NotNull AndroidDbErrorReporter reporter) {
  try {
    final InputStream is = new BufferedInputStream(URLUtil.openStream(url));
    final OutputStream os = new BufferedOutputStream(new FileOutputStream(file));

    try {
      FileUtil.copy(is, os);
    }
    finally {
      is.close();
      os.close();
    }
  }
  catch (IOException e) {
    reporter.reportError(e);
    return false;
  }
  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:AndroidDbUtil.java

示例7: getBundledGdslFiles

import com.intellij.util.io.URLUtil; //导入依赖的package包/类
private static List<VirtualFile> getBundledGdslFiles() {
  final List<VirtualFile> result = ContainerUtil.newArrayList();
  for (File file : getBundledScriptFolders()) {
    if (file.exists()) {
      File[] children = file.listFiles();
      if (children != null) {
        for (File child : children) {
          final String fileName = child.getName();
          if (fileName.endsWith(".gdsl")) {
            String path = FileUtil.toSystemIndependentName(child.getPath());
            String url = VirtualFileManager.constructUrl(URLUtil.FILE_PROTOCOL, path);
            ContainerUtil.addIfNotNull(result, VirtualFileManager.getInstance().refreshAndFindFileByUrl(url));
          }
        }
      }
    }
  }
  return result;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:GroovyDslFileIndex.java

示例8: testLocationUrl

import com.intellij.util.io.URLUtil; //导入依赖的package包/类
@Override
public String testLocationUrl(
    @Nullable Kind kind, String parentSuite, String name, @Nullable String className) {
  // ignore initial value of className -- it's the test runner class.
  name = StringUtil.trimTrailing(name, '-');
  if (!name.contains("-")) {
    return SmRunnerUtils.GENERIC_SUITE_PROTOCOL + URLUtil.SCHEME_SEPARATOR + name;
  }
  int ix = name.lastIndexOf('-');
  className = name.substring(0, ix);
  String methodName = name.substring(ix + 1);
  return SmRunnerUtils.GENERIC_SUITE_PROTOCOL
      + URLUtil.SCHEME_SEPARATOR
      + className
      + SmRunnerUtils.TEST_NAME_PARTS_SPLITTER
      + methodName;
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:18,代码来源:BlazeAndroidTestEventsHandler.java

示例9: pathToUrl

import com.intellij.util.io.URLUtil; //导入依赖的package包/类
protected static String pathToUrl(File path) {
  String name = path.getName();
  boolean isJarFile =
      FileUtilRt.extensionEquals(name, "jar") || FileUtilRt.extensionEquals(name, "zip");
  // .jar files require an URL with "jar" protocol.
  String protocol =
      isJarFile
          ? StandardFileSystems.JAR_PROTOCOL
          : VirtualFileSystemProvider.getInstance().getSystem().getProtocol();
  String filePath = FileUtil.toSystemIndependentName(path.getPath());
  String url = VirtualFileManager.constructUrl(protocol, filePath);
  if (isJarFile) {
    url += URLUtil.JAR_SEPARATOR;
  }
  return url;
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:17,代码来源:BlazeLibrary.java

示例10: getSpecs2TestUrl

import com.intellij.util.io.URLUtil; //导入依赖的package包/类
@Nullable
private static String getSpecs2TestUrl(ScClass testClass, ScInfixExpr testCase) {
  String name = null;
  String protocol = null;
  if (TestNodeProvider.isSpecs2ScopeExpr(testCase)) {
    protocol = SmRunnerUtils.GENERIC_SUITE_PROTOCOL;
    name = Specs2Utils.getSpecs2ScopeName(testCase);
  } else if (TestNodeProvider.isSpecs2Expr(testCase)) {
    protocol = SmRunnerUtils.GENERIC_TEST_PROTOCOL;
    name = Specs2Utils.getSpecs2ScopedTestName(testCase);
  }
  if (name == null) {
    return null;
  }
  return protocol
      + URLUtil.SCHEME_SEPARATOR
      + testClass.getQualifiedName()
      + SmRunnerUtils.TEST_NAME_PARTS_SPLITTER
      + name;
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:21,代码来源:BlazeScalaTestRunLineMarkerContributor.java

示例11: loadText

import com.intellij.util.io.URLUtil; //导入依赖的package包/类
@NotNull
public static String loadText(@NotNull URL url) throws IOException {
  InputStream inputStream = new BufferedInputStream(URLUtil.openStream(url));

  InputStreamReader reader = new InputStreamReader(inputStream, ENCODING_UTF_8);
  try {
    StringBuilder text = new StringBuilder();
    char[] buf = new char[5000];
    while (reader.ready()) {
      final int length = reader.read(buf);
      if (length == -1) break;
      text.append(buf, 0, length);
    }
    return text.toString();
  }
  finally {
    reader.close();
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:20,代码来源:ResourceUtil.java

示例12: HaxeClasspathEntry

import com.intellij.util.io.URLUtil; //导入依赖的package包/类
public HaxeClasspathEntry(@Nullable String name, @NotNull String url) {
  myName = name;
  myUrl = url;

  // Try to fix the URL if it wasn't correct.
  if (!url.contains(URLUtil.SCHEME_SEPARATOR)) {
    if (LOG.isDebugEnabled()) {
      LOG.debug("Fixing malformed URL passed by " + HaxeDebugUtil.printCallers(5));
    }
    VirtualFileSystem vfs = VirtualFileManager.getInstance().getFileSystem(LocalFileSystem.PROTOCOL);
    VirtualFile file = vfs.findFileByPath(url);
    if (null != file) {
      myUrl = file.getUrl();
    }
  }

  if (null != myName) {
    if (HaxelibNameUtil.isManagedLibrary(myName)) {
      myName = HaxelibNameUtil.parseHaxelib(myName);
      myIsManagedEntry = true;
    }
  }
}
 
开发者ID:HaxeFoundation,项目名称:intellij-haxe,代码行数:24,代码来源:HaxeClasspathEntry.java

示例13: toUri

import com.intellij.util.io.URLUtil; //导入依赖的package包/类
/**
 * @return correct URL, must be used only for external communication
 */
@Nonnull
public static URI toUri(@Nonnull VirtualFile file) {
  String path = file.getPath();
  try {
    String protocol = file.getFileSystem().getProtocol();
    if (file.isInLocalFileSystem()) {
      if (SystemInfo.isWindows && path.charAt(0) != '/') {
        path = '/' + path;
      }
      return new URI(protocol, "", path, null, null);
    }
    if (URLUtil.HTTP_PROTOCOL.equals(protocol)) {
      return new URI(URLUtil.HTTP_PROTOCOL + URLUtil.SCHEME_SEPARATOR + path);
    }
    return new URI(protocol, path, null);
  }
  catch (URISyntaxException e) {
    throw new IllegalArgumentException(e);
  }
}
 
开发者ID:consulo,项目名称:consulo,代码行数:24,代码来源:VfsUtil.java

示例14: loadBundledScheme

import com.intellij.util.io.URLUtil; //导入依赖的package包/类
@Override
public void loadBundledScheme(@Nonnull String resourceName, @Nonnull Object requestor, @Nonnull ThrowableConvertor<Element, T, Throwable> convertor) {
  try {
    URL url = requestor instanceof AbstractExtensionPointBean
              ? (((AbstractExtensionPointBean)requestor).getLoaderForClass().getResource(resourceName))
              : DecodeDefaultsUtil.getDefaults(requestor, resourceName);
    if (url == null) {
      // Error shouldn't occur during this operation thus we report error instead of info
      LOG.error("Cannot read scheme from " + resourceName);
      return;
    }
    addNewScheme(convertor.convert(JDOMUtil.load(URLUtil.openStream(url))), false);
  }
  catch (Throwable e) {
    LOG.error("Cannot read scheme from " + resourceName, e);
  }
}
 
开发者ID:consulo,项目名称:consulo,代码行数:18,代码来源:SchemesManagerImpl.java

示例15: toDecodedForm

import com.intellij.util.io.URLUtil; //导入依赖的package包/类
@Override
public String toDecodedForm() {
  StringBuilder builder = new StringBuilder();
  if (scheme != null) {
    builder.append(scheme);
    if (authority != null || isInLocalFileSystem()) {
      builder.append(URLUtil.SCHEME_SEPARATOR);
    }
    else {
      builder.append(':');
    }

    if (authority != null) {
      builder.append(authority);
    }
  }
  builder.append(getPath());
  if (parameters != null) {
    builder.append(parameters);
  }
  return builder.toString();
}
 
开发者ID:consulo,项目名称:consulo,代码行数:23,代码来源:UrlImpl.java


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