Example usage for org.springframework.batch.item.file FlatFileParseException FlatFileParseException

List of usage examples for org.springframework.batch.item.file FlatFileParseException FlatFileParseException

Introduction

In this page you can find the example usage for org.springframework.batch.item.file FlatFileParseException FlatFileParseException.

Prototype

public FlatFileParseException(String message, String input, int lineNumber) 

Source Link

Usage

From source file:org.jasig.ssp.util.importer.job.csv.FlatFileItemReaderNewLine.java

private String applyRecordSeparatorPolicy(String line) throws IOException {

    String record = line;/*from ww  w  . j av a 2s  .  c  om*/
    while (line != null && !recordSeparatorPolicy.isEndOfRecord(record)) {
        line = this.reader.readLine();
        if (line == null) {
            if (StringUtils.hasText(record)) {
                // A record was partially complete since it hasn't ended but
                // the line is null
                throw new FlatFileParseException("Unexpected end of file before record complete", record,
                        lineCount);
            } else {
                // Record has no text but it might still be post processed
                // to something (skipping preProcess since that was already
                // done)
                break;
            }
        } else {
            lineCount++;
        }
        record = recordSeparatorPolicy.preProcess(record) + line;
    }

    return recordSeparatorPolicy.postProcess(record);

}