Basically, I am caching a bunch of files in memory. The problem is, if I get too many files cached into memory I can run out of memory.

Is there any sort of java memory structure that will automatically page part of itself to disk? 

For example, I would like to set a 2 mb limit the size of the files in memory. After that limit I would like some of the files to be written to disk.

Is there any library that does this sort of thing?

Grae