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