Here you can find the source of saveImage(String imageUrl, String destinationFile)
public static void saveImage(String imageUrl, String destinationFile) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.URL; public class Main { public static void saveImage(String imageUrl, String destinationFile) throws IOException { URL url = new URL(imageUrl); InputStream is = url.openStream(); OutputStream os = new FileOutputStream(destinationFile); byte[] b = new byte[2048]; int length; while ((length = is.read(b)) != -1) { os.write(b, 0, length);/*from w w w . j av a 2 s . c o m*/ } is.close(); os.close(); } }