jxl读取excel需要关闭Workbook?
/** * 简单的读取excel * @param inputFile * @param inputFileSheetIndex * @throws Exception */public static ArrayList<String> sampleReadExcel(File inputFile, int inputFileSheetIndex) throws Exception {ArrayList<String> list = new ArrayList<String>();Workbook book = null;Cell cell = null;//避免乱码的设置WorkbookSettings setting = new WorkbookSettings(); java.util.Locale locale = new java.util.Locale("zh","CN"); setting.setLocale(locale);setting.setEncoding("ISO-8859-1");book = Workbook.getWorkbook(inputFile, setting);Sheet sheet = book.getSheet(inputFileSheetIndex);for (int rowIndex = 0; rowIndex < sheet.getRows(); rowIndex++) {// Excel第一行为表头,因此J初值设为1for (int colIndex = 0; colIndex < sheet.getColumns(); colIndex++) {// 只需从Excel中取出2列cell = sheet.getCell(colIndex, rowIndex);list.add(cell.getContents());}}//【问题:如果在实际部署的时候没有写下面这句是否会导致不断消耗掉服务器的内存?jxl里面有个ReadWrite.java没有关闭读的,只关闭了写的】book.close();return list;} 1 楼 jiyanliang 2008-04-23 它会把所有数据都读到内存中,如果数据量太大的时候,就肯定暴了