Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to load a image from web in java

Tags:

java

image

I need to load an image from a web in a simple Java stand alone aplication. Any Ideas?


2 Answers

You can load an image using

BufferedImage img = ImageIO.read(new URL("http://stackoverflow.com/content/img/so/logo.png"));

For methods how to display the loaded image, see the Sun "Working with images" tutorial.

like image 62
rodion Avatar answered Sep 12 '25 19:09

rodion


URL url = new URL("http://host/theimage.jpg");
URLConnection conn = url.openConnection();
InputStream in = conn.getInputStream();

is that enough to start you? Don't know what you want to do from there.

like image 40
Gary Kephart Avatar answered Sep 12 '25 20:09

Gary Kephart