File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 Murach's Java Servlets and JSP this week in the Servlets 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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Caching big arrays
 
Similar Threads
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
copying arrays from one arraylist to another arraylist