Results 1 to 2 of 2
  1. #1
    Valeriano is offline Member
    Join Date
    May 2007
    Posts
    10
    Rep Power
    0

    Default How to download an image from a HTTP URL

    I want to download an image from a HTTP url and show it to the user. I know how to show an image to the user if it is in the form of Image/BufferedImage but i dont know how to download it. Should i use a third party library or does Java have a built-in support for this?

  2. #2
    levent Guest

    Default

    Yes, Java has excellent built-in support for networking.

    You can use the following code to download the image:

    Java Code:
    try {
            // Create a URL for the image's location
            URL url = new URL("http://your-host.com/your-image.gif");
        
            // Get the image
            java.awt.Image image = java.awt.Toolkit.getDefaultToolkit().getDefaultToolkit().createImage(url);
    
        } catch (MalformedURLException e) {
        } catch (IOException e) {
        }

Similar Threads

  1. Download JDK 1.5
    By Nick15 in forum New To Java
    Replies: 4
    Last Post: 01-01-2009, 04:10 AM
  2. image download from server
    By willemjav in forum Java Applets
    Replies: 2
    Last Post: 04-03-2008, 11:13 PM
  3. Replies: 0
    Last Post: 01-08-2008, 06:29 PM
  4. What jdk do I download?
    By padutch2 in forum New To Java
    Replies: 3
    Last Post: 11-29-2007, 05:28 AM
  5. I could download JDK 1.5
    By Albert in forum New To Java
    Replies: 2
    Last Post: 07-13-2007, 04:36 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •