🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #14670

Problems copying image from URL

#14670
From: pqvist
Date: Thu, 12 Aug 1999 00:00
36 lines
1560 bytes
Hi,

I desperatly need some help with my simple application. The application
takes one argument, wich is an URL to an image.
The application shall then save the image to a local filesystem. this is
where I get trouble!

Please help me,

Johan

********************************

import java.net.*;
import java.io.*;
public class auto {
 public static void main(String [] args) {
 try {
  URL url= new URL(args[0]);
  System.out.println("MIME: " + url.openConnection().getContentType());
  Object cont = url.getContent();
  System.out.println("ImageProducer: " + (cont instanceof
java.awt.image.ImageProducer));
  System.out.println("InputStream: " + (cont instanceof InputStream));
  File outputFile = new File(url.getFile());

/************************************
/ Here I need your help!
/ How do I save the image given as an argument input to disk?
/ i.e. "http://validator.w3.org/images/vh40.gif"
/ When I tried I had serilazation errors.
/************************************/

 } catch (IOException e) {System.out.println(e);}
 }
}
Technical Details
Message-ID: <7ouf1r$f668@forums.borland.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,9e04cf47c0aa9909,start
X-Google-Attributes: gidf74b3,public
From: <pqvist@hotmail.com>
Subject: Problems copying image from URL
Date: 1999/08/12
Message-ID: <7ouf1r$f668@forums.borland.com>
X-Deja-AN: 511832276
X-Priority: 3
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2014.211
Organization: Another Netscape Collabra Server User
X-MSMail-Priority: Normal
Newsgroups: borland.public.jbuilder.java.language