@@ -0,0 +1,2127 @@
+package io.github.benas.easybatch.core.util;%0A%0Aimport io.github.benas.easybatch.core.api.Record;%0Aimport io.github.benas.easybatch.core.api.RecordReader;%0A%0Aimport java.util.Scanner;%0A%0A/**%0A * A convenient %7B@link RecordReader%7D that reads data from a String.%0A *%0A * @author benas (md.benhassine@gmail.com)%0A */%0Apublic class StringRecordReader implements RecordReader %7B%0A%0A    /**%0A     * The current read record number.%0A     */%0A    private long currentRecordNumber;%0A%0A    /**%0A     * Scanner to read input String.%0A     */%0A    private Scanner scanner;%0A%0A    /**%0A     * A second scanner used to calculate the number of records in the input file.%0A     * The main scanner may be used instead but since the %7B@link Scanner%7D class does not have a method to rewind it to the%0A     * beginning of the file ( %7B@link java.util.Scanner#reset()%7D does not rewind the scanner), another scanner instance is needed.%0A     */%0A    private Scanner recordCounterScanner;%0A%0A    /**%0A     * The content of the String data source.%0A     */%0A    private String content;%0A%0A    /**%0A     * Constructs a StringRecordReader.%0A     * @param content The String data source%0A     */%0A    public StringRecordReader(final String content) %7B%0A        this.content = content;%0A    %7D%0A%0A    @Override%0A    public void open() throws Exception %7B%0A        currentRecordNumber = 0;%0A        scanner = new Scanner(content);%0A        recordCounterScanner = new Scanner(content);%0A    %7D%0A%0A    @Override%0A    public boolean hasNextRecord() %7B%0A        return scanner.hasNextLine();%0A    %7D%0A%0A    @Override%0A    public Record readNextRecord() %7B%0A        currentRecordNumber++;%0A        return new StringRecord(currentRecordNumber, scanner.nextLine());%0A    %7D%0A%0A    @Override%0A    public long getTotalRecords() %7B%0A        long totalRecords = 0;%0A        while (recordCounterScanner.hasNextLine()) %7B%0A            totalRecords++;%0A            recordCounterScanner.nextLine();%0A        %7D%0A        recordCounterScanner.close();%0A        return totalRecords;%0A    %7D%0A%0A    @Override%0A    public String getDataSourceName() %7B%0A        return %22In-Memory String%22;%0A    %7D%0A%0A    @Override%0A    public void close() %7B%0A        scanner.close();%0A    %7D%0A%7D%0A

add a convenient record reader to read data from an in-memory String data source