jayesh
jayesh

Reputation: 2492

How do I write an integer value to a csv file using opencsv

This is my code for writing a csv file

CSVWriter writer = new CSVWriter(new FileWriter("test.csv",false));
String [] details = new String[]{"00000002","0","0","0","0","type_detils","01","1","-1","0.0","0.0","CST"};
writer.writeNext(details);

I want to write this value format in csv:

00000002,0,0,0,0,"type_detils",01,1,-1,0.0,0.0,"CST"

But when I look in the file it's like this:

"00000002","0","0","0","0","type_detils","01","1","-1","0.0","0.0","CST"

How can I change the string value to an integer during the file write using opencsv?

Upvotes: 2

Views: 4615

Answers (1)

LCE
LCE

Reputation: 934

You can try the 3 param constructor (link) like this:

CSVWriter writer = new CSVWriter(new FileWriter("test.csv",false),',','\0');

Using the '\0' is the null char. Or perhaps pass null if the CSVWriter accepts it.

Upvotes: 1

Related Questions