Java Code Examples for com.intellij.util.io.URLUtil#openStream()
The following examples show how to use
com.intellij.util.io.URLUtil#openStream() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ResourceUtil.java From consulo with Apache License 2.0 | 6 votes |
@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(); } }
Example 2
Source File: DecodeDefaultsUtil.java From consulo with Apache License 2.0 | 5 votes |
@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; } }
Example 3
Source File: UrlUtil.java From consulo with Apache License 2.0 | 4 votes |
public static String loadText(URL url) throws IOException { try (InputStream stream = new BufferedInputStream(URLUtil.openStream(url))) { return new String(FileUtil.loadBytes(stream), FileTemplate.ourEncoding); } }