public class CsvWriterApi extends CsvApiBase
save() method.
CSV writer API can use save() only one time.CELLS_DEFAULT_SPLITTER, cellsSplitter, csvRows, filePath, headerList| Constructor and Description |
|---|
CsvWriterApi(String filePath)
Constructor.
|
CsvWriterApi(String filePath,
CellsSplitterEnum cellsSplitter)
Constructor.
|
CsvWriterApi(String filePath,
char cellsSplitter)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addRow(List<String> row)
Add a row to CSV body.
|
void |
addRow(List<String> row,
int index)
Add a row to CSV body in index.
|
void |
addRows(List<List<String>> rowList)
Add a row to CSV body.
|
boolean |
isCsvSaved()
Is
save() was executed. |
void |
removeRow(int index)
Remove a row from CSV body in index place.
|
void |
save()
Save CSV to file.
|
void |
setHeaders(List<String> headerList)
Set CSV headers.
|
public CsvWriterApi(String filePath)
filePath - CSV file path.public CsvWriterApi(String filePath, CellsSplitterEnum cellsSplitter)
filePath - CSV file path.cellsSplitter - Cells splitter enum.public CsvWriterApi(String filePath, char cellsSplitter)
filePath - CSV file path.cellsSplitter - Cells splitter char.public void setHeaders(List<String> headerList) throws CsvOperationException, io.github.tuzon.projects.core.expections.InvalidValueException
headerList - Header list.CsvOperationException - in case user call the method more than one time,
or run setHeaders(List) after running save() method.io.github.tuzon.projects.core.expections.InvalidValueException - in case header list is null or headers amount is different from row size.public void addRow(List<String> row) throws io.github.tuzon.projects.core.expections.InvalidValueException, CsvOperationException
row - A row of cells.io.github.tuzon.projects.core.expections.InvalidValueException - in case row is null or row size is different
from previous headers amount or rows size.CsvOperationException - in case run adding a row after CSV file already been saved.public void addRow(List<String> row, int index) throws io.github.tuzon.projects.core.expections.InvalidValueException, IndexOutOfBoundsException, CsvOperationException
row - A row of cells.index - Index of row in CSV body.io.github.tuzon.projects.core.expections.InvalidValueException - in case row is null, or index is negative.IndexOutOfBoundsException - in case index is out of row bounds.CsvOperationException - in case run adding a row after CSV file already been saved.public void addRows(List<List<String>> rowList) throws io.github.tuzon.projects.core.expections.InvalidValueException, CsvOperationException
rowList - List of rows.io.github.tuzon.projects.core.expections.InvalidValueException - in case rowList is null.CsvOperationException - in case run adding rows after CSV file already been saved.public void removeRow(int index)
throws io.github.tuzon.projects.core.expections.InvalidValueException,
IndexOutOfBoundsException,
CsvOperationException
index - Index of the row to be removed.io.github.tuzon.projects.core.expections.InvalidValueException - in case index is negative number.IndexOutOfBoundsException - in case index is out of CSV rows bounds.CsvOperationException - in case remove a row after CSV file already been saved.public void save()
throws IOException,
CsvOperationException
IOException - in case fail to save CSV file.CsvOperationException - in case CSV file already been saved.public boolean isCsvSaved()
save() was executed.Copyright © 2019. All rights reserved.