Create an Image from a URL in Java

Description

The following code shows how to create an Image from a URL.

Example


//w ww  .  ja va  2  s  .  com
import java.awt.Image;
import java.awt.Toolkit;
import java.net.URL;

public class Main {
  public static void main(String[] argv) throws Exception {
    URL url = new URL("http://hostname:80/image.gif");

    Image image = Toolkit.getDefaultToolkit().getDefaultToolkit().createImage(url);
  }
}




















Home »
  Java Tutorial »
    Network »




NetworkInterface
URI
URL
HTTP
HTTP Read
IP
Socket
UDP
URL Encode