Class CSVFile

java.lang.Object
com.axelor.common.csv.CSVFile

public final class CSVFile extends Object
This class provides api to work with csv files using CSVParser and CSVPrinter.
  • Field Details

    • DEFAULT

      public static final CSVFile DEFAULT
    • EXCEL

      public static final CSVFile EXCEL
  • Method Details

    • withDelimiter

      public CSVFile withDelimiter(char delimiter)
    • withEscape

      public CSVFile withEscape(char escape)
    • withQuoteAll

      public CSVFile withQuoteAll()
    • withFirstRecordAsHeader

      public CSVFile withFirstRecordAsHeader()
    • withHeader

      public CSVFile withHeader(String... header)
    • parse

      public org.apache.commons.csv.CSVParser parse(InputStream in) throws IOException
      Throws:
      IOException
    • parse

      public org.apache.commons.csv.CSVParser parse(InputStream in, Charset charset) throws IOException
      Throws:
      IOException
    • parse

      public org.apache.commons.csv.CSVParser parse(Reader in) throws IOException
      Throws:
      IOException
    • parse

      public org.apache.commons.csv.CSVParser parse(File in) throws IOException
      Throws:
      IOException
    • parse

      public org.apache.commons.csv.CSVParser parse(File in, Charset charset) throws IOException
      Throws:
      IOException
    • write

      public org.apache.commons.csv.CSVPrinter write(Writer out) throws IOException
      Throws:
      IOException
    • write

      public org.apache.commons.csv.CSVPrinter write(OutputStream out, Charset charset) throws IOException
      Throws:
      IOException
    • write

      public org.apache.commons.csv.CSVPrinter write(File out, Charset charset) throws IOException
      Throws:
      IOException
    • write

      public org.apache.commons.csv.CSVPrinter write(File out) throws IOException
      Throws:
      IOException
    • parse

      public void parse(File in, Consumer<org.apache.commons.csv.CSVParser> task) throws IOException
      Throws:
      IOException
    • parse

      public void parse(Reader in, Consumer<org.apache.commons.csv.CSVParser> task) throws IOException
      Throws:
      IOException
    • stream

      public static Stream<org.apache.commons.csv.CSVRecord> stream(org.apache.commons.csv.CSVParser parser)
      Return a stream of CSVRecord by filtering out empty records.
      Parameters:
      parser - the CSVParser
      Returns:
      stream of CSVRecord
    • header

      public static String[] header(org.apache.commons.csv.CSVParser parser)
      Return header as array.
      Parameters:
      parser - the CSVParser
      Returns:
      array of header names
    • values

      public static String[] values(org.apache.commons.csv.CSVRecord record)
      Return values as array.
      Parameters:
      record - the CSVRecord
      Returns:
      array of values
    • isEmpty

      public static boolean isEmpty(org.apache.commons.csv.CSVRecord record)
      Check whether the record is empty.
      Parameters:
      record - the CSVRecord
      Returns:
      true if record is empty
    • notEmpty

      public static boolean notEmpty(org.apache.commons.csv.CSVRecord record)
      Check whether the record is not empty.
      Parameters:
      record - the CSVRecord
      Returns:
      true if record is not empty