Ejemplo n.º 1
0
 public static String read(URL target) throws IOException {
   InputStream in = target.openStream();
   ByteArrayOutputStream out = new ByteArrayOutputStream();
   IOUtils.transfer(in, out, 8 * 1024);
   in.close();
   return out.toString(Utils.getCharset().name());
 }
Ejemplo n.º 2
0
  public PageReader(URL target) throws IOException {
    protocol = target.getProtocol();
    host = target.getHost();
    file = target.getFile();
    address = target.toString();

    InputStream in = target.openStream();
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    IOUtils.transfer(in, out, 8 * 1024);
    in.close();
    contents = Utils.getString(out.toByteArray());
  }