import java.io.*; import java.net.URL; String imageURL = (String) context.get("imageURL"); InputStream is = null; OutputStream os = service.getOutputStream(); try { is = new URL(imageURL).openStream(); byte[] b = new byte[2048]; int length; while ((length = is.read(b)) != -1) { os.write(b, 0, length); } os.flush(); } finally { if (is != null) { is.close(); } }