java - How can I tell SuperCSV NOT to map empty string to null -


i using icsvlistreader , icsvlistwriter read , write csv file.
i found empty string in csv file converted null , output.
how can avoid happen. i've tried create new cellprocessor:

private cellprocessor[] getprocessors(int columnnumber){          cellprocessor[] processors = new cellprocessor[columnnumber];         (int i=0; i< columnnumber; i++){             processors[i] = new convertnullto("");         }         return processors;     } 

but still not working.

is there way change setting?

empty columns don't require escaping in csv (so default super csv won't apply quotes around empty strings), if want quotes applied can change quotemode in super csv.

here's recent example on demonstrates this.

update: if want quote empty strings, make sure values you're writing empty string (i.e. may need use convertnullto("")), use following quote mode:

public class quoteemptystring implements quotemode {      /**      * {@inheritdoc}      */     @override     public boolean quotesrequired(string csvcolumn, csvcontext context,          csvpreference preference) {         return "".equals(csvcolumn);     }  } 

Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -