You are on page 1of 1

package org.

example;
//package com.cloud.customers.utils;

import java.io.BufferedWriter;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

import org.apache.commons.csv.CSVFormat;
import org.apache.commons.csv.CSVPrinter;

class ExportDataToCsv {
private static final String SAMPLE_CSV_FILE = "users.csv";
private static Object ExportDataToCsv;

public void exportDataToCsv() throws IOException {


BufferedWriter writer =
Files.newBufferedWriter(Paths.get(SAMPLE_CSV_FILE));
CSVPrinter csvPrinter = new CSVPrinter(writer,
CSVFormat.DEFAULT.withHeader("customerId", "locationId"));
Map<String, String> data = new HashMap<String, String>();
for (Map.Entry<String, String> entry : data.entrySet()) {
csvPrinter.printRecord(Arrays.asList(entry.getKey(),
entry.getValue()));
}
csvPrinter.flush();
}
public static void main(){
ExportDataToCsv=new ExportDataToCsv();
}
}

You might also like