Here is the code I already have, I need to next dynamically store the contents of the file we were given into the string array pieLabels. I cannot figure out how to do this though, any help would be greatly appreciated!
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.Scanner;
public class P9 implements Interface{
String[] pieLabels;
double[] pieElements;
double[] barElements;
double[] secondBarElements;
double[] lineElements;
double[] lineSecond;
double[] lineThird;
@Override
public boolean readFile(String filename){
try {
int pieNum = 0; int barNum = 0; int lineNum 0;
Scanner fileReader = new Scanner(new File(filename));
if(fileReader.hasNextInt()){
pieNum = fileReader.nextInt();
}
if(fileReader.hasNextInt()){
barNum = fileReader.nextInt();
}
if(fileReader.hasNextInt()){
lineNum = fileReader.nextInt();
}
//this is where I should store it
fileReader.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
}
return false;
}
@Override
public String getTitle(eType type) {
// TODO Auto-generated method stub
return null;
}
@Override
public String[] getLabels(eType type) {
// TODO Auto-generated method stub
return null;
}
@Override
public double[] getData(eType type, int series) {
// TODO Auto-generated method stub
return null;
}
}