public class

FileImageCache

extends Object
implements ImageCache
java.lang.Object
   ↳ com.neomades.content.image.FileImageCache

Class Overview

LRU Disk Image cache with size limit (by default 8MB)

Summary

Public Constructors
FileImageCache(File dir)
Creates a file image cache with 8 M-Bytes of Last-Recent-Used images.
FileImageCache(File dir, int maxSize)
Creates a file image cache with a user-defined cache size of Last-Recent-Used images.
Public Methods
void clear()
Clears the file image cache.
void close()
Closes the file cache.
Image getImage(String url)
Reads the Image from cache for the URL given in parameter.
InputStream getImageAsStream(String url)
Reads the image stream from cache for the URL given in parameter.
void putImage(String url, Image bitmap)
Saves an image to the cache.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.neomades.content.image.ImageCache

Public Constructors

public FileImageCache (File dir)

Creates a file image cache with 8 M-Bytes of Last-Recent-Used images.

Do not use the same directory with different caches of FileCache and FileImageCache or other stuffs. FileImageCache will delete all the files which is not a file handled by this cache.

public FileImageCache (File dir, int maxSize)

Creates a file image cache with a user-defined cache size of Last-Recent-Used images.

Parameters
dir directory to save images
maxSize size in KB

Public Methods

public void clear ()

Clears the file image cache.

public void close ()

Closes the file cache.

Throws
IOException

public Image getImage (String url)

Reads the Image from cache for the URL given in parameter.

Returns
  • the image associated to the URL in the cache or null if not found

public InputStream getImageAsStream (String url)

Reads the image stream from cache for the URL given in parameter.

Returns
  • the stream associated to the URL in the cache or null if not found

public void putImage (String url, Image bitmap)

Saves an image to the cache.