views:

25

answers:

1
+1  Q: 

Applet Image Cache

Hi SO.

I have an applet that shows a couple of images. A lot (10-20) of these images is identical, and is fetched from the internet in a non-parallel way. Is there an imagecache that I can use? So I only fetch the same image once, or do I have to make my own?

Thanks

A: 

Much depends on your needs, but I'm guessing you want a minimal footprint in an Applet. This very simple example uses a List implementation to cache images by index. To ease making the list circular, the same index is used in a parallel list of names. In your case, a suitable Map<String, Image> implementation might be simpler. If memory is tight, LinkedHashMap can be used as a Simple (LRU) Cache in Java.

trashgod