Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

JPG handling within Java

Status
Not open for further replies.

D4VEHUG

Technical User
Mar 5, 2004
6
0
0
GB
I am relatively new to Java but understand the OO aspect.

Can anyone tell me how to handle transfering a jpg from a URL to hard disk, in Java. This is what I want a section of my program to do.

Any pointers would be most welcome.

Thankyou.

Dave
 
Code:
import java.net.*;
import java.io.*;
...

URL u = new URL("[URL unfurl="true"]http://bla.com/image/bla.jpg");[/URL]
HttpUrlConnection huc = (HttpUrlConnection)u.openConnection();
InputStream is = huc.getInputStream();
FileOutputStream fos = new FileOutputStream("afile.jpg");
// Then read the 'is' stream and write it out to the 'fos' stream ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top