嗨,我从.xls
工作表中读取数据,其中包含8500
行数据,我试图将其存储在double[][]
中,但出现错误
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
码
public static double[][] getData_DoubleArray(String path, int sheetNo, int rowIndex1, int rowIndex2) {
double[][] doubleArray=null;
try {
HSSFSheet sheet = PS_ExcelReader.getWorkSheet(path,sheetNo);
System.out.println("sheet" + sheet);
List<Object> data1 = PS_ExcelReader.getFullColumnByIndex(sheet, rowIndex1);
List<Object> data2 = PS_ExcelReader.getFullColumnByIndex(sheet, rowIndex2);
doubleArray = new double[data1.size()][data2.size()];
for(int i = 0; i < data1.size(); i++) {
for(int j = 0; j < data2.size(); j++) {
doubleArray[i][0] = (Double)data1.get(i);
doubleArray[i][1] = (Double)data2.get(j);
}
}
System.out.println("array " + Arrays.deepToString(doubleArray));
}
catch(IOException ioe) {
log.error("data mis match");
}
return doubleArray;
}
最佳答案
在您的Java文件中,您必须使用double []数组。我认为您没有为数组声明合适的大小