Java tutorial
//package com.java2s; import java.io.BufferedInputStream; import java.io.ByteArrayOutputStream; import java.io.InputStream; import java.net.URL; import java.net.URLConnection; import android.util.Log; public class Main { private static final String TAG = "WareNinjaUtils"; public static byte[] loadImageDataFromWeb(String url) { byte[] imageData = null; try { URLConnection connection = new URL(url).openConnection(); InputStream stream = connection.getInputStream(); //BufferedInputStream in=new BufferedInputStream(stream);//default 8k buffer BufferedInputStream in = new BufferedInputStream(stream, 10240);//YG: 10k=10240, 2x8k=16384 ByteArrayOutputStream out = new ByteArrayOutputStream(10240); int read; byte[] b = new byte[4096]; while ((read = in.read(b)) != -1) { out.write(b, 0, read); } out.flush(); out.close(); imageData = out.toByteArray(); } catch (Exception e) { Log.w(TAG, "Exc=" + e); return null; } return imageData; } }