src/main/java/utils/Common.java
/**
     * <p>Exports a list of {@link SearchResultItem} to a CSV file</p>
     * <p>Supports comma and quotes in the {@link SearchResultItem} title</p>
     *
     * @param path path to valid directory with valid filename
     * @param items List of {@link SearchResultItem}
     * @throws IOException by {@link FileWriter} when path is not valid
     */
Exports a list of  SearchResultItem to a CSV file
Supports comma and quotes in the  SearchResultItem title

@param path path to valid directory with valid filename
@param items List of  SearchResultItem
@throws IOException by  FileWriter when path is not valid
Exports a list of SearchResultItem to a CSV file Supports comma and quotes in the SearchResultItem title @param path path to valid directory with valid filename @param items List of SearchResultItem @throws IOException by FileWriter when path is not valid
public static void exportSearchItemsToCSV(String path, List<SearchResultItem> items) throws IOException {
        CSVWriter writer = new CSVWriter(new FileWriter(path));
        String[] header = new String[]{"Title", "Price New", "Price Used", "URL"};
        writer.writeNext(header);
        List<String[]> allData = new ArrayList<>();
        for (SearchResultItem i : items){
            String[] data = new String[]{i.getTitle(), String.valueOf(i.getPriceNew()), String.valueOf(i.getPriceUsed()), i.getUrl()};
            allData.add(data);
        }
        writer.writeAll(allData);
        writer.close();
    }
public static void exportSearchItemsToCSV ( String path , List < SearchResultItem > items ) throws IOException { CSVWriter writer = new CSVWriter ( new FileWriter ( path ) ) ; String [ ] header = new String [ ] { "Title" , "Price New" , "Price Used" , "URL" } ; writer . writeNext ( header ) ; List < String [ ] > allData = new ArrayList < > ( ) ; for ( SearchResultItem i : items ) { String [ ] data = new String [ ] { i . getTitle ( ) , String . valueOf ( i . getPriceNew ( ) ) , String . valueOf ( i . getPriceUsed ( ) ) , i . getUrl ( ) } ; allData . add ( data ) ; } writer . writeAll ( allData ) ; writer . close ( ) ; }
<p>Exports a list of {@link SearchResultItem} to a CSV file</p>
 <p>Supports comma and quotes in the {@link SearchResultItem} title</p>
<p > Exports a list of { @link SearchResultItem } to a CSV file< / p > <p > Supports comma and quotes in the { @link SearchResultItem } title< / p >