I have de next code:
String test = "A,B,,,,,";
String[] result = test.split(",");
for(String s : result){
System.out.println("$"+s+"$");
}
The output is:
$A$
$B$
and y I expected:
$A$
$B$
$$
$$
$$
$$
$$
but, I modified the code as follows:
String test = "A,B,,,,,C";
String[] result = test.split(",");
for(String s : result){
System.out.println("$"+s+"$");
}
and the result is:
$A$
$B$
$$
$$
$$
$$
$C$
other variation:
String test = "A,B,,,C,,";
String[] result = test.split(",");
for(String s : result){
System.out.println("$"+s+"$");
}
the result:
$A$
$B$
$$
$$
$C$
any idea?
I need this for convert csv file to java objects, but when they don't send me the last column the code not work correctly
String[] result = test.split(",",test.length());, and you'll see that you get your expected results.