This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Java in General and the fly likes Caching big arrays Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Caching big arrays" Watch "Caching big arrays" New topic
Author

Caching big arrays

Serge Papin
Greenhorn

Joined: Aug 09, 2005
Posts: 2
Is there a ready-to-use solution for working with big arrays in Java so that only a part of the array is in memory and everything else is stored on disk?
Thanks.
Stephen Huey
Ranch Hand

Joined: Jul 15, 2003
Posts: 618
I don't know of anything like that in the API...
Rick O'Shay
Ranch Hand

Joined: Sep 19, 2004
Posts: 531
NIO has classes that do just that. It's a fundamental requirement for a serious server environment and was added in Java 1.4. NIO used to be done using native method interfaces and that's no longer required.

http://javaalmanac.com/egs/java.nio/CreateMemMap.html
Serge Papin
Greenhorn

Joined: Aug 09, 2005
Posts: 2
Originally posted by Rick O'Shay:
NIO has classes that do just that. It's a fundamental requirement for a serious server environment and was added in Java 1.4. NIO used to be done using native method interfaces and that's no longer required.

http://javaalmanac.com/egs/java.nio/CreateMemMap.html


Thanks Rick.
So do you suggest creating FileChannel and using position() and read()/write() methods to do the job? Wouldn't that be too expensive and slow?
I thought of much more sophisticated approach.
Rick O'Shay
Ranch Hand

Joined: Sep 19, 2004
Posts: 531
Impossible to say without analyzing your requirements. The disk is slower but usually plenty fast depending on the application and the bits are dirt cheap. Actually, I think dirts a little more
 
Don't get me started about those stupid light bulbs.
 
subject: Caching big arrays
 
Similar Threads
copying arrays from one arraylist to another arraylist
JSPs, Servlets and EJB's??
How many objects are created by the following two statements?
how to split byte[] to smaller chunks
Books, books, books.. Mastering EJB 3.0