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


Java URLUtil.openStream方法代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: loadText

import com.intellij.util.io.URLUtil; //导入方法依赖的package包/类
@Nonnull
public static String loadText(@Nonnull 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:consulo,项目名称:consulo,代码行数:20,代码来源:ResourceUtil.java

示例5: getDefaultsInputStream

import com.intellij.util.io.URLUtil; //导入方法依赖的package包/类
@Nullable
public static InputStream getDefaultsInputStream(Object requestor, @NotNull String componentResourcePath) {
  try {
    final URL defaults = getDefaults(requestor, componentResourcePath);
    return defaults == null ? null : URLUtil.openStream(defaults);
  }
  catch (IOException e) {
    LOG.error(e);
    return null;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:DecodeDefaultsUtil.java

示例6: loadText

import com.intellij.util.io.URLUtil; //导入方法依赖的package包/类
public static String loadText(URL url) throws IOException {
  final InputStream stream = new BufferedInputStream(URLUtil.openStream(url));
  try {
    return new String(FileUtil.loadBytes(stream), FileTemplate.ourEncoding);
  }
  finally {
    stream.close();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:UrlUtil.java

示例7: getDefaultsInputStream

import com.intellij.util.io.URLUtil; //导入方法依赖的package包/类
@Nullable
public static InputStream getDefaultsInputStream(Object requestor, final String componentResourcePath) {
  try {
    final URL defaults = getDefaults(requestor, componentResourcePath);
    return defaults != null ? URLUtil.openStream(defaults) : null;
  }
  catch (IOException e) {
    LOG.error(e);
    return null;
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:12,代码来源:DecodeDefaultsUtil.java

示例8: getOutputText

import com.intellij.util.io.URLUtil; //导入方法依赖的package包/类
@Nullable
private String getOutputText(ExportTestResultsConfiguration config) throws IOException, TransformerException, SAXException {
  ExportTestResultsConfiguration.ExportFormat exportFormat = config.getExportFormat();

  SAXTransformerFactory transformerFactory = (SAXTransformerFactory)SAXTransformerFactory.newInstance();
  TransformerHandler handler;
  if (exportFormat == ExportTestResultsConfiguration.ExportFormat.Xml) {
    handler = transformerFactory.newTransformerHandler();
    handler.getTransformer().setOutputProperty(OutputKeys.INDENT, "yes");
    handler.getTransformer().setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
  }
  else {
    Source xslSource;
    if (config.getExportFormat() == ExportTestResultsConfiguration.ExportFormat.BundledTemplate) {
      URL bundledXsltUrl = getClass().getResource("intellij-export.xsl");
      xslSource = new StreamSource(URLUtil.openStream(bundledXsltUrl));
    }
    else {
      File xslFile = new File(config.getUserTemplatePath());
      if (!xslFile.isFile()) {
        showBalloon(myRunConfiguration.getProject(), MessageType.ERROR,
                    ExecutionBundle.message("export.test.results.custom.template.not.found", xslFile.getPath()), null);
        return null;
      }
      xslSource = new StreamSource(xslFile);
    }
    handler = transformerFactory.newTransformerHandler(xslSource);
    handler.getTransformer().setParameter("TITLE", ExecutionBundle.message("export.test.results.filename", myRunConfiguration.getName(),
                                                                           myRunConfiguration.getType().getDisplayName()));
  }

  StringWriter w = new StringWriter();
  handler.setResult(new StreamResult(w));
  TestResultsXmlFormatter.execute(myModel.getRoot(), myRunConfiguration, handler);
  return w.toString();
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:37,代码来源:ExportTestResultsAction.java

示例9: getOutputText

import com.intellij.util.io.URLUtil; //导入方法依赖的package包/类
@Nullable
private String getOutputText(ExportTestResultsConfiguration config) throws IOException, TransformerException, SAXException {
  ExportTestResultsConfiguration.ExportFormat exportFormat = config.getExportFormat();

  SAXTransformerFactory transformerFactory = (SAXTransformerFactory)SAXTransformerFactory.newInstance();
  TransformerHandler handler;
  if (exportFormat == ExportTestResultsConfiguration.ExportFormat.Xml) {
    handler = transformerFactory.newTransformerHandler();
    handler.getTransformer().setOutputProperty(OutputKeys.INDENT, "yes");
    handler.getTransformer().setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
  }
  else {
    Source xslSource;
    if (config.getExportFormat() == ExportTestResultsConfiguration.ExportFormat.BundledTemplate) {
      URL bundledXsltUrl = getClass().getResource("intellij-export.xsl");
      xslSource = new StreamSource(URLUtil.openStream(bundledXsltUrl));
    }
    else {
      File xslFile = new File(config.getUserTemplatePath());
      if (!xslFile.isFile()) {
        showBalloon(myRunConfiguration.getProject(), MessageType.ERROR,
                    ExecutionBundle.message("export.test.results.custom.template.not.found", xslFile.getPath()), null);
        return null;
      }
      xslSource = new StreamSource(xslFile);
    }
    handler = transformerFactory.newTransformerHandler(xslSource);
    handler.getTransformer().setParameter("TITLE", ExecutionBundle.message("export.test.results.filename", myRunConfiguration.getName(),
                                                                           myRunConfiguration.getType().getDisplayName()));
  }

  StringWriter w = new StringWriter();
  handler.setResult(new StreamResult(w));
  try {
    TestResultsXmlFormatter.execute(myModel.getRoot(), myRunConfiguration, myModel.getProperties(), handler);
  }
  catch (ProcessCanceledException e) {
    return null;
  }
  return w.toString();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:42,代码来源:ExportTestResultsAction.java

示例10: loadText

import com.intellij.util.io.URLUtil; //导入方法依赖的package包/类
public static String loadText(URL url) throws IOException {
  try (InputStream stream = new BufferedInputStream(URLUtil.openStream(url))) {
    return new String(FileUtil.loadBytes(stream), FileTemplate.ourEncoding);
  }
}
 
开发者ID:consulo,项目名称:consulo,代码行数:6,代码来源:UrlUtil.java


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