You are here:

Java/Pagination in Java

Advertisement


Question
Hi,
I wish to know about the pagination concept in Java. Suppose I need to work with a string which is very long and it can't be put into the RAM all at once. Is there any feature in Java which helps us divide the string into pages, so that we can lift the required portion and manipulate it while leaving the rest.

Thanks

Answer
You can map a file into memory which I think does what you are asking:

RandomAccessFile file = new RandomAccessFile("<temp file location>", "rw");
FileChannel channel = file.getChannel();
MappedByteBuffer buffer = channel.map(FileChannel.MapMode.READ_WRITE, <start>, <size>);

//now read/write to buffer


Note that you can only map 2 gigs per MappedByteBuffer. You will need to create multiple buffers for each 2 gig chunk.

Java

All Answers


Answers by Expert:


Ask Experts

Volunteer


Artemus Harper

Expertise

I have a Masters in computer science. I can answer questions on core J2SE, swing and graphics. Please no questions about JSP or J2ME.

Experience

I have experience in Core Java, good background in Java swing/gui, some experience with JNI, Java reflection. Some experience in bio-informatics. Basics in c++ and c#

Organizations
Washington State University

Education/Credentials
MS in Computer Science from Washington State University and a BS in Mathematics and Computer Science from Central Washington University.

©2016 About.com. All rights reserved.