/** * 次のレコードの有無を返す。 * * @return */ public boolean next() { if (!iter.hasNext() && !EOF) { try { iter = readBuffer().iterator(); } catch (IOException ioe) { ioe.printStackTrace(); return false; } } if (iter.hasNext()) { CSVLineParser parser = (CSVLineParser) iter.next(); defaultString = parser.getDefaultString(); currentRow = new CSVRecordMap(); String[] cols = parser.getSeparatedValues(); for (int i = 0; i < cols.length; i++) currentRow.put(colmunName[i], cols[i]); currentRowNum++; return true; } else { defaultString = null; currentRow = null; return false; } }
/** * ファイルの先頭行よりタイトルを読み込みます * * @return * @throws IOException */ public CSVReader preLoadTitleRow() throws IOException { BufferedReader br = null; try { br = new BufferedReader(new InputStreamReader(new FileInputStream(file), encode)); CSVLineParser parser = readLine(br, new CSVLineParser()); offset = readIndex; colmunName = parser.getSeparatedValues(); } finally { if (br != null) br.close(); } return this; }