CSVPrinter - printing integer value in new line

Viewed 138

I'm using apache commons CSV lib to generate a CSV file. I have a list of String arrays, which contains both string and integer value. But when I print the values it's generating integer value as a new row.

public void printValues(Writer writer){
  List<String[]> values = new ArrayList<>();
  String[] someValues = new String[]{"ABC","XYZ","123","PQR"};
  values.add(someValues);

  CSVPrinter printer = new CSVPrinter(writer,CSVFormat.EXCEL);
  printer.printRecords(values);
}

Above code is giving output

ABC,XYZ
123,"PQR"

Whereas it should return

ABC,XYZ,123,PQR
0 Answers
Related