I have the code bellow which reading a file to Arraylist and convert it to 2D array :
public double [][] filetoArray(String fileName)
throws IOException
{
ArrayList result = new ArrayList();
File aFile = new File(fileName);
BufferedReader reader = new BufferedReader(new FileReader(aFile));
String aLine = null;
while ((aLine = reader.readLine()) != null)
{
//result.add(aLine + ",");
result.add(aLine);
//aLine = reader.readLine();
}
String[][] data = new String[result.size()][result.size()];
for(int i =0; i < result.size()/2; i++){
for(int j =0; j <2; j++){
data[i][j]= (String) result.get(j +( result.size() * i));
}
}
I have an error ( filetoarray) can not cast string to double ? i have also array out of bound exception when just use the string type with out casting to double?
any suggestion please