Even I though about using a Vector , ArrayList but I want it to be like one single structure. Example : One Arraylist will have one row , so I need to have 5-10 such rows in a structure similar to a database table.

Thanks,
Aditya

SCJP 1.5

Campbell Ritchie

Sheriff

Posts: 51453

87

posted 7 years ago

You need a class which holds those data, then set up an array of that class. You can alter the size of the array by creating a new array and copying elements as the number retained changes.

Adi Kulkarni

Ranch Hand

Posts: 86

posted 7 years ago

Thanks Campbell,

So do you mean that for every record I should create an object of that class eg new MyClass(parameter1,parameter2,parameter3,...,parameterN) and store this in ArrayList <MyClass> or Array.

So I shall need getter and setter methods for accessing those values and once my job is done for that particular row , I can discard those object instances.

This is because ,I need to parse a file with around 20000000 lines/rows. And the data for processing would be around 5-10 line/rows.

Thanks,
Aditya

SCJP 1.5

Campbell Ritchie

Sheriff

Posts: 51453

87

posted 7 years ago

You said 5-10 rows earlier. Yes, that sort of data structure is what I meant.

For that many instances, you will probably need to put them into SQL, otherwise you will overwhelm the amount of heap space available.

Campbell Ritchie

Sheriff

Posts: 51453

87

posted 7 years ago

Make all the data final in your instances, and forget about set methods.

Adi Kulkarni

Ranch Hand

Posts: 86

posted 7 years ago

So that means for processing a data of 5-10 rows I can use a class with those many final class variables.

Ok , I shall try executing that

Thanks,
Aditya

SCJP 1.5

Campbell Ritchie

Sheriff

Posts: 51453

87

posted 7 years ago

It would appear in a database as 5-10 columns. If you wish to use that class to record data, make it into an immutable class. Making all the variables final is only part of that.

Adi Kulkarni

Ranch Hand

Posts: 86

posted 7 years ago

Thanks Campbell,
One query

I have the following application.

A CSV file having around 8 to 10 comma separated fields. This file is approximately 6GB big with 20000000 rows.

As a part of processing this file, I need to store around 5-10 rows in a buffer/data structure.