How do i put this listproduct
List<GetProductModel> listProduct = new ArrayList<>();
GetProductModel
private String ProductName,Description,Price; //getter and setter
to this list
List<String[]> list = new ArrayList<>();
so i can put list to
try (CSVWriter writer = new CSVWriter(new FileWriter("c:\\test\\monitor.csv"))) {
writer.writeAll(list);
} catch (Exception e) {
e.printStackTrace();
}
you can you use for loop or Streams like:
List<String[]> list = listProduct.stream()
.filter(Objects::nonNull)
.map(getProductModel -> new String[]{getProductModel.getProductName(), getProductModel.getDescription(), getProductModel.getPrice()})
.collect(Collectors.toList());