Java URL Read readURL(URL url)

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

Description

read URL

License

Apache License

Declaration

public static final byte[] readURL(URL url) throws IOException 

Method Source Code

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

import java.io.IOException;
import java.io.InputStream;

import java.net.URL;
import java.net.URLConnection;

public class Main {
    public static final byte[] readURL(URL url) throws IOException {
        URLConnection urlconnection = url.openConnection();
        InputStream inputstream = urlconnection.getInputStream();
        int i = urlconnection.getContentLength();
        if (i <= 0)
            i = inputstream.available();
        if (i <= 0)
            return null;
        byte abyte0[] = new byte[i];
        for (int j = 0; j < i; j += inputstream.read(abyte0, j, i - j))
            ;//from  w  ww . j  ava2s.c o m
        return abyte0;
    }
}

Related

  1. readUrl(final String url_str)
  2. readURL(String path)
  3. readUrl(String url_str)
  4. readUrl(String urlString)
  5. readUrl(URL url)
  6. readUrl(URL url, String[]... headers)
  7. readURL(URLConnection connection, String charset)
  8. readUrlContent(URLConnection connection)
  9. readURLToString(String url)