Home | History | Annotate | Download | only in io

Lines Matching full:url

26 import java.net.URL;
32 * Note that even those these methods use {@link URL} parameters, they
45 * read from the given URL.
47 * @param url the URL to read from
51 final URL url) {
52 checkNotNull(url);
55 return url.openStream();
62 * {@link InputStreamReader} that read a URL using the given character set.
64 * @param url the URL to read from
65 * @param charset the character set used when reading the URL contents
69 URL url, Charset charset) {
70 return CharStreams.newReaderSupplier(newInputStreamSupplier(url), charset);
74 * Reads all bytes from a URL into a byte array.
76 * @param url the URL to read from
77 * @return a byte array containing all the bytes from the URL
80 public static byte[] toByteArray(URL url) throws IOException {
81 return ByteStreams.toByteArray(newInputStreamSupplier(url));
85 * Reads all characters from a URL into a {@link String}, using the given
88 * @param url the URL to read from
89 * @param charset the character set used when reading the URL
90 * @return a string containing all the characters from the URL
93 public static String toString(URL url, Charset charset) throws IOException {
94 return CharStreams.toString(newReaderSupplier(url, charset));
98 * Streams lines from a URL, stopping when our callback returns false, or we
101 * @param url the URL to read from
102 * @param charset the character set used when reading the URL
107 public static <T> T readLines(URL url, Charset charset,
109 return CharStreams.readLines(newReaderSupplier(url, charset), callback);
113 * Reads all of the lines from a URL. The lines do not include
117 * @param url the URL to read from
122 public static List<String> readLines(URL url, Charset charset)
124 return CharStreams.readLines(newReaderSupplier(url, charset));
128 * Copies all bytes from a URL to an output stream.
130 * @param from the URL to read from
134 public static void copy(URL from, OutputStream to) throws IOException {
139 * Returns a {@code URL} pointing to {@code resourceName} if the resource is
145 public static URL getResource(String resourceName) {
146 URL url = Resources.class.getClassLoader().getResource(resourceName);
147 checkArgument(url != null, "resource %s not found.", resourceName);
148 return url;
152 * Returns a {@code URL} pointing to {@code resourceName} that is relative to
157 public static URL getResource(Class<?> contextClass, String resourceName) {
158 URL url = contextClass.getResource(resourceName);
159 checkArgument(url != null, "resource %s relative to %s not found.",
161 return url;