Package com.axelor.common.csv
Class CSVFile
java.lang.Object
com.axelor.common.csv.CSVFile
This class provides api to work with csv files using
CSVParser and CSVPrinter.-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic String[]header(org.apache.commons.csv.CSVParser parser) Return header as array.static booleanisEmpty(org.apache.commons.csv.CSVRecord record) Check whether the record is empty.static booleannotEmpty(org.apache.commons.csv.CSVRecord record) Check whether the record is not empty.org.apache.commons.csv.CSVParserorg.apache.commons.csv.CSVParservoidorg.apache.commons.csv.CSVParserparse(InputStream in) org.apache.commons.csv.CSVParserparse(InputStream in, Charset charset) org.apache.commons.csv.CSVParservoidstatic Stream<org.apache.commons.csv.CSVRecord> stream(org.apache.commons.csv.CSVParser parser) Return a stream ofCSVRecordby filtering out empty records.static String[]values(org.apache.commons.csv.CSVRecord record) Return values as array.withDelimiter(char delimiter) withEscape(char escape) withHeader(String... header) org.apache.commons.csv.CSVPrinterorg.apache.commons.csv.CSVPrinterorg.apache.commons.csv.CSVPrinterwrite(OutputStream out, Charset charset) org.apache.commons.csv.CSVPrinter
-
Field Details
-
DEFAULT
-
EXCEL
-
-
Method Details
-
withDelimiter
-
withEscape
-
withQuoteAll
-
withFirstRecordAsHeader
-
withHeader
-
parse
- Throws:
IOException
-
parse
- Throws:
IOException
-
parse
- Throws:
IOException
-
parse
- Throws:
IOException
-
parse
- Throws:
IOException
-
write
- Throws:
IOException
-
write
public org.apache.commons.csv.CSVPrinter write(OutputStream out, Charset charset) throws IOException - Throws:
IOException
-
write
- Throws:
IOException
-
write
- Throws:
IOException
-
parse
- Throws:
IOException
-
parse
- Throws:
IOException
-
stream
public static Stream<org.apache.commons.csv.CSVRecord> stream(org.apache.commons.csv.CSVParser parser) Return a stream ofCSVRecordby filtering out empty records.- Parameters:
parser- theCSVParser- Returns:
- stream of
CSVRecord
-
header
Return header as array.- Parameters:
parser- theCSVParser- Returns:
- array of header names
-
values
Return values as array.- Parameters:
record- theCSVRecord- Returns:
- array of values
-
isEmpty
public static boolean isEmpty(org.apache.commons.csv.CSVRecord record) Check whether the record is empty.- Parameters:
record- theCSVRecord- 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- theCSVRecord- Returns:
- true if record is not empty
-