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
posted
0
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.
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://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.