Question: Processing large amounts of data can be challenging because it must fit in memory. A way of trading off is to keep the data on

Processing large amounts of data can be challenging because it must fit in memory. A way of trading off is to keep the data on disk and read it only as needed for processing, but this comes at the cost of time since disk access is slower.how do I write a class called IntDiskArray that abstracts reading and writing an "array" that is kept strictly on disk. You will support the operations as follows:

IntDiskArray(String filename, int size). The constructor takes the name of the file and the size of the "array." If the file exists then it should be opened and its size calculated (ignoring the size parameter). If the file doesn't exist, then create it and write "size" binary zeros to the file. Use the exists() and length() method of the File class for some of this.

close(). Closes the "array" on disk.

get(int index). Reads the data from the "array" at the given index. Use the seek() method for this, but remember to convert from index to byte offset. Check for bounds on the "array."

put(int index, int data). Write the data to the "array" at the given index. Again, use seek(). Check for bounds on the "array."

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!