javaparsingcsv

How can I separate tokens when there are some null tokens


I have a line in the .csv file as abc,bcc,

I have to separate it into three tokens abc, bcc and null.

First, I tried StringTokenizer but it did not return a null token. Then, I tried String.split(",") but it also did not return null at the end; it returned a string which has null in between but not at the end.

so please help me thanks in advance.


Solution

  • Try the String.split() variant that takes a limit and pass a negative number to it.