Java URL Load readFromUrl(URL url)

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

Description

read From Url

License

Open Source License

Declaration

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

Method Source Code


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

import java.io.*;
import java.net.URL;

public class Main {
    public static byte[] readFromUrl(URL url) throws IOException {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        byte[] buffer = new byte[8192];
        int i;//from www  .  j a  va  2  s .co  m
        try (InputStream is = url.openStream()) {
            while ((i = is.read(buffer)) != -1) {
                baos.write(buffer, 0, i);
            }
        }
        return baos.toByteArray();
    }
}

Related

  1. readFromFile(URL fileName)
  2. readFromFile(URL source)
  3. readFromUrl(String url)
  4. readFromUrl(String urlString)
  5. readFromUrl(String urlText)
  6. readFromURL(URL url)
  7. readGOMappingFile(URL filename, Set secondAttributeList)
  8. readHttpBytes(String url)
  9. readHttpFile(final String urlStr)

  10. HOME | Copyright © www.java2s.com 2016