wood burning stoves*
The moose likes Beginning Java and the fly likes getting images from web Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "getting images from web" Watch "getting images from web" New topic
Author

getting images from web

Goat Boy
Greenhorn

Joined: Jul 09, 2005
Posts: 1
Hi all
I want my program to get number of images from the web
http://www.url.com/img01.jpg
.
.
.
http://www.url.com/img99.jpg
What should I use in order to read images and save it to my hard drive?
URL url = new URL("http://www.url.com/img01.jpg");
InputStream is = urlConnection.getInputStream();
something like that?
but it does not work and I don't know how to "convert" inputstream to file....
Please help!
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
One possiblity is to also create an OutputStream that writes to a file. You can then read the data from the InputStream you created from the URL and write it to this OutputStream.

HTH

Layne


Java API Documentation
The Java Tutorial
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
Here are some example snippets. We usually don't like giving away too much of the solution, but these IO thingies are hard to assemble by just reading the docs ...

You could surely be more efficient by reading and writing arrays of bytes, but I have some other code in between read & write to check for various conditions. I leave it to you to detect EOF.

BTW: Change your user name before the law comes around. It should be a believable first & last name, tho not necessarily your real name. Mine isn't.
[ July 09, 2005: Message edited by: Stan James ]

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: getting images from web