Java URL Load loadFromURL(URL url)

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

Description

load From URL

License

Open Source License

Declaration

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

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.ByteArrayOutputStream;

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

import java.net.URL;

public class Main {
    public static byte[] loadFromURL(URL url) throws IOException {
        InputStream is = null;// w  w  w  .j av  a 2s .com
        try {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            is = url.openStream();
            int r;
            byte[] buffer = new byte[8000];
            while ((r = is.read(buffer)) >= 0) {
                if (r == 0)
                    continue;
                baos.write(buffer, 0, r);
            }
            return baos.toByteArray();
        } finally {
            if (is != null)
                is.close();
        }
    }
}

Related

  1. loadFile(URL resource)
  2. loadFile(URL url)
  3. loadFileNoArray(URL f)
  4. loadFileOrUrlToList(String iFileOrUrl)
  5. loadFromUrl(String url)
  6. loadFromURL(URL url)
  7. loadFromURL(URL url)
  8. loadFully(URL url)
  9. loadFully(URL url)