@Test(expected = CanNotOpenStreamException.class) public void read_unreachable_url() throws IOException { final String unreachable = "http: UrlUtil.read(new URL(unreachable), CHARSET); }
public static String read(@Nonnull final URL url, @Nonnull final Charset charset) throws IOException { Check.notNull(url, "url"); Check.notNull(charset, "charset"); final InputStream inputStream = open(url); BufferedReader reader = null; final StringBuilder buffer = new StringBuilder(); boolean threw = true; try { reader = new BufferedReader(new InputStreamReader(inputStream, charset)); buffer.append(readAll(reader)); threw = false; } finally { Closeables.close(reader, threw); Closeables.close(inputStream, false); } return buffer.toString(); }
UrlUtil { public static String read(@Nonnull final URL url, @Nonnull final Charset charset) throws IOException { Check.notNull(url, "url"); Check.notNull(charset, "charset"); final InputStream inputStream = open(url); BufferedReader reader = null; final StringBuilder buffer = new StringBuilder(); boolean threw = true; try { reader = new BufferedReader(new InputStreamReader(inputStream, charset)); buffer.append(readAll(reader)); threw = false; } finally { Closeables.close(reader, threw); Closeables.close(inputStream, false); } return buffer.toString(); } }
UrlUtil { public static String read(@Nonnull final URL url, @Nonnull final Charset charset) throws IOException { Check.notNull(url, "url"); Check.notNull(charset, "charset"); final InputStream inputStream = open(url); BufferedReader reader = null; final StringBuilder buffer = new StringBuilder(); boolean threw = true; try { reader = new BufferedReader(new InputStreamReader(inputStream, charset)); buffer.append(readAll(reader)); threw = false; } finally { Closeables.close(reader, threw); Closeables.close(inputStream, false); } return buffer.toString(); } private  UrlUtil(); }
UrlUtil { public static String read(@Nonnull final URL url, @Nonnull final Charset charset) throws IOException { Check.notNull(url, "url"); Check.notNull(charset, "charset"); final InputStream inputStream = open(url); BufferedReader reader = null; final StringBuilder buffer = new StringBuilder(); boolean threw = true; try { reader = new BufferedReader(new InputStreamReader(inputStream, charset)); buffer.append(readAll(reader)); threw = false; } finally { Closeables.close(reader, threw); Closeables.close(inputStream, false); } return buffer.toString(); } private  UrlUtil(); static URL build(@Nonnull final String url); static InputStream open(@Nonnull final URL url); static String read(@Nonnull final URL url, @Nonnull final Charset charset); static URL toUrl(@Nonnull final File file); }
UrlUtil { public static String read(@Nonnull final URL url, @Nonnull final Charset charset) throws IOException { Check.notNull(url, "url"); Check.notNull(charset, "charset"); final InputStream inputStream = open(url); BufferedReader reader = null; final StringBuilder buffer = new StringBuilder(); boolean threw = true; try { reader = new BufferedReader(new InputStreamReader(inputStream, charset)); buffer.append(readAll(reader)); threw = false; } finally { Closeables.close(reader, threw); Closeables.close(inputStream, false); } return buffer.toString(); } private  UrlUtil(); static URL build(@Nonnull final String url); static InputStream open(@Nonnull final URL url); static String read(@Nonnull final URL url, @Nonnull final Charset charset); static URL toUrl(@Nonnull final File file);  }