@Override public boolean hasNext() { if (CSVParser.this.isClosed()) { return false; } if (this.current == null) { this.current = this.getNextRecord(); } return this.current != null; }
@Override public CSVRecord next() { if (CSVParser.this.isClosed()) { throw new NoSuchElementException("CSVParser has been closed"); } CSVRecord next = this.current; this.current = null; if (next == null) { // hasNext() wasn't called before next = this.getNextRecord(); if (next == null) { throw new NoSuchElementException("No more CSV records available"); } } return next; }
/** * Checks, if the parser instance was closed. * * @return true, if the parser was closed, otherwise false */ public final boolean isClosed() { return this.parser.isClosed(); }
@Override public void close() throws IOException { if (!parser.isClosed()) { parser.close(); } } }
@Override public boolean hasNext() { if (CSVParser.this.isClosed()) { return false; } if (this.current == null) { this.current = this.getNextRecord(); } return this.current != null; }
@Override public boolean hasNext() { if (CSVParser.this.isClosed()) { return false; } if (this.current == null) { this.current = this.getNextRecord(); } return this.current != null; }
@Override public boolean hasNext() { if (CSVParser.this.isClosed()) { return false; } if (this.current == null) { this.current = this.getNextRecord(); } return this.current != null; }
@Override public CSVRecord next() { if (CSVParser.this.isClosed()) { throw new NoSuchElementException("CSVParser has been closed"); } CSVRecord next = this.current; this.current = null; if (next == null) { // hasNext() wasn't called before next = this.getNextRecord(); if (next == null) { throw new NoSuchElementException("No more CSV records available"); } } return next; }
@Override public CSVRecord next() { if (CSVParser.this.isClosed()) { throw new NoSuchElementException("CSVParser has been closed"); } CSVRecord next = this.current; this.current = null; if (next == null) { // hasNext() wasn't called before next = this.getNextRecord(); if (next == null) { throw new NoSuchElementException("No more CSV records available"); } } return next; }
@Override public CSVRecord next() { if (CSVParser.this.isClosed()) { throw new NoSuchElementException("CSVParser has been closed"); } CSVRecord next = this.current; this.current = null; if (next == null) { // hasNext() wasn't called before next = this.getNextRecord(); if (next == null) { throw new NoSuchElementException("No more CSV records available"); } } return next; }
/** * closeParser() method is used to release resources created to read the CSV file * * @param isOrdered bool indicating whether the entries in CSV file are ordered or not */ public void closeParser(String fileName, boolean isOrdered) { try { if (fileReader != null) { fileReader.close(); } if (isOrdered) { if (bufferedReader != null) { bufferedReader.close(); } } else { if (csvParser != null && !csvParser.isClosed()) { csvParser.close(); } } } catch (IOException e) { log.error("Error occurred when closing CSV resources used for CSV file '" + fileName + "'", e); } if (log.isDebugEnabled()) { log.debug("Close resources used for CSV file '" + fileName + "'."); } }