Java URL Load loadURL(URL url)

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

Description

load URL

License

Open Source License

Declaration

public static byte[] loadURL(URL url) throws IOException 

Method Source Code


//package com.java2s;
import java.net.*;
import java.io.*;

public class Main {
    public static byte[] loadURL(URL url) throws IOException {
        int bufSize = 1024 * 2;
        byte[] buf = new byte[bufSize];

        ByteArrayOutputStream bout = new ByteArrayOutputStream();
        BufferedInputStream in = new BufferedInputStream(url.openStream());
        int n;//from www. j a va2 s. c o m
        while ((n = in.read(buf)) > 0) {
            bout.write(buf, 0, n);
        }
        try {
            in.close();
        } catch (Exception ignored) {
        }
        return bout.toByteArray();
    }
}

Related

  1. loadPropertiesFromURL(URL url)
  2. loadProps(URL url, Properties props)
  3. loadRemoteJSON(final URL source)
  4. loadText(URL url, boolean allowCache)
  5. loadURL(String urlDesc)
  6. loadURL(URL url)
  7. loadUrlIntoByteArray(String urlString)
  8. loadUrlToList(URL iUrl)
  9. loadURLToString(String url, String EOL)