tags:

views:

216

answers:

2

i have line in .csv file as abc,bcc,

i have to separate it into three tokens as abc bcc and null

first i had try stringTokenizer but it will not return null token so after that i try string.split(",") but it will not return the last null string it will return string which has null in between but not at last

so please help me thanks in advance.

+1  A: 

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

Joachim Sauer
+2  A: 

use the two argument split with a negative second argument

String str = "abc,bcc,";
String[] tokens = str.split(",", -1);

split(String, int) documentation

Carlos Heuberger