テキストファイルから配列に情報を保存しようとしていますが、プロジェクトは、一時的な配列を作成し、新しいオブジェクトに対応するためにさらに多くのファイルを読み取るにつれてそのサイズを大きくすることでそうするように求めています. これどうやってするの?
/**
* reads a csv data file and returns an array of acquaintances
* @param path File path of CSV file
* @return Acquaintances from the file
*/
public static Acquaintance[] read (String path) {
//create an array of acquaintances
Acquaintance[] acqs = new Acquaintance[0];
//open the file
try {
BufferedReader file = new BufferedReader(new FileReader(path));
//read the file until the end
String line;
while( (line = file.readLine()) != null) {
// parse the line just read
String[] parts = line.split(",");
//create an acquaintance object
Acquaintance a = new Acquaintance(parts[0], parts[1], Double.parseDouble(parts[2]));
acqs[0] = a;
//Add the object to the array
//(1) create a new Acquaintance array, with one extra element
Acquaintance[] tmp = new Acquaintance[acqs.length+1];
//(2) copy all old elements into new
Acquaintance[] tmp = acqs.clone();
//(3) assign new Acquaintance object to last element of the array
//(4) assign new array's address to acqs
//for loop
}