public void populateDBInfo() { Iterator<Table> it = Tables.iterator(); String fileName, line; Pages P; TableList TL = null; Table T; int recCount, pageCount; while (it.hasNext()) { // for all the tables T = it.next(); P = null; TL = null; fileName = pathForData + T.getTableName() + ".csv"; recCount = 0; pageCount = 0; try { BufferedReader br = new BufferedReader(new FileReader(fileName)); // create an empty page P = new Pages(recCount, pageSize, pageCount++); while ((line = br.readLine()) != null) { // process the line. if (P.checkSpace(line.length())) { P.insertRec(line); recCount += 1; } else { // save the current page TL = new TableList(P.getStartId(), P.getEndId(), P.getPageId(), P.getAvailableSpace()); T.insertPage(P); T.insertTableList(TL); /*System.out.println(T.noOfPages); for (String s : P.recordsInPage ){ System.out.println(s); }*/ T.noOfPages += 1; // start a new page to store records. P = new Pages(recCount, pageSize, pageCount++); if (P.checkSpace(line.length())) { P.insertRec(line); recCount += 1; } } } br.close(); } catch (FileNotFoundException e) { // Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // Auto-generated catch block e.printStackTrace(); } // saving the last page if (P.getAvailableSpace() < pageSize) { TL = new TableList(P.getStartId(), P.getEndId(), P.getPageId(), P.getAvailableSpace()); T.insertPage(P); T.insertTableList(TL); /*System.out.println(T.noOfPages); for (String s : P.recordsInPage ){ System.out.println(s); }*/ T.noOfPages += 1; } } }