downloading images from URL
807591Mar 25 2008 — edited Mar 26 2008Hi All,
I am trying to write code to download images from given URL. My application will take URLs by querying sql server, will pass that URL to my method and download images to a specific folder. There will be almost 400 images a day to download. I figured out some options like getImage(). But I would like to get idea from you to find the most efficient way to do this.
Here is the initial code I have come up with
private void downloadimage() throws Exception {
String sql = "SET NOCOUNT ON SELECT DISTINCT activation_group_id FROM ACTIVATION_GROUP";
JdoServer jdo = JdoServer.getInstance(dbKey);
RowSet rs = jdo.getRowSet(sql);
while (rs.next())
{
//will fetch URL from rs here, currently passing hardcoded URL for testing purpose.
// Get the image
MediaTracker tracker;
tracker = new MediaTracker(this);
Toolkit toolkit = Toolkit.getDefaultToolkit();
Image image = toolkit.getImage(new URL ("http://digitalcontent.cnetchannel.com/70/e1/70e18a07-7356-4a54-8498-1493da1dec3d.jpg"));
tracker.addImage(image, 0);
}
}
Somehow, tracker = new MediaTracker(this) is giving me the consstructor mediatracker(myclassname) not defined error.
I am a recent graduate and it's my first project... any help would be appreciated :)
Thanks