Here you can find the source of downloadImage(String url)
public static BufferedImage downloadImage(String url)
//package com.java2s; //License from project: Open Source License import java.awt.image.BufferedImage; import java.io.IOException; import java.net.HttpURLConnection; import java.net.URL; import javax.imageio.ImageIO; public class Main { public static BufferedImage downloadImage(String url) { HttpURLConnection connection = null; try {/*w ww .jav a2s.c om*/ connection = (HttpURLConnection) new URL(url).openConnection(); connection.connect(); BufferedImage image = ImageIO.read(connection.getInputStream()); connection.disconnect(); return image; } catch (IOException e) { e.printStackTrace(); if (connection != null) { connection.disconnect(); } return null; } } }