Load Object Bytes from a URL

private static byte[] loadFromURL(URL url) throws IOException {
	   ByteArrayOutputStream baos = new ByteArrayOutputStream();
	   InputStream is = url.openStream();
	   int r;
	   byte[] buffer = new byte[1000];

	   while ((r = is.read(buffer)) >= 0) {
	     if (r == 0)
	     baos.write(buffer, 0, r);
	   return baos.toByteArray();

You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.

AddThis Social Bookmark Button

Similar Posts

Comments are closed.