Class CsvSupport.LineReader

java.lang.Object
io.jenetics.ext.util.CsvSupport.LineReader
Enclosing class:
CsvSupport

public static final class CsvSupport.LineReader extends Object
This class reads CSV files and splits it into lines. It takes a quote character as a parameter, which is necessary for not splitting on quoted line feeds.
final var csv = """
    0.0,0.0000
    0.1,0.0740
    0.2,0.1120
    0.3,0.1380
    0.4,0.1760
    0.5,0.2500
    0.6,0.3840
    0.7,0.6020
    0.8,0.9280
    0.9,1.3860
    1.0,2.0000
    """;

final var reader = new LineReader(new Quote('"'));
try (Stream<String> lines = reader.read(new StringReader(csv))) {
    lines.forEach(System.out::println);
}
Since:
8.1
Version:
8.1
API Note:
This reader obeys escaped line breaks according RFC-4180.
  • Constructor Details

  • Method Details

    • read

      public Stream<String> read(Reader reader)
      Reads all CSV lines from the given reader.
      Parameters:
      reader - the reader from which to read the CSV content
      Returns:
      the CSV lines from the file as a Stream
      API Note:
      This method must be used within a try-with-resources statement or similar control structure to ensure that the stream's open file is closed promptly after the stream's operations have completed.