Tag Archives: table

Java: read table with empty elements.

Suppose you have a table, tab or "," delimited. Look like this:

element1,element2,element3,element4

element21,,,element24

If you read each line and do
split(",");

The result will be a 2 element String[] for 2nd line. Because java will ignore the repeated ",".

The solution to this is to do split(",",-1);