Java URL Load readURL(URL url)

Here you can find the source of readURL(URL url)

Description

read URL

License

Apache License

Declaration

private static String readURL(URL url) throws IOException 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;

public class Main {
    private static String readURL(URL url) throws IOException {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        InputStream is = url.openStream();
        int r;/*  w  w w.j  a  v a 2 s .  c  om*/
        while ((r = is.read()) != -1) {
            baos.write(r);
        }
        return new String(baos.toByteArray());
    }
}

Related

  1. readURL(URL fileURL)
  2. readURL(URL url)
  3. readUrl(URL url)
  4. readURL(URL url)
  5. readURL(URL url)
  6. readURLasString(URL url)
  7. readUrlContent(String address)
  8. readURLContents(String UrlText)
  9. readURLJSONArray(String urlString)