I'm reading from a .csv File line by line. One line could look for example as following: String str = "10,1,,,,"
.
Now I would like to split according to ",": String[] splitted = str.split(",");
The problem now is that this only results in 2 elements but I would like to have 5 elements, the first two elements should contain 10 and 1 and the other 3 should be just an empty String.
Another example is String str = "0,,,,,"
which results in only one element but I would like to have 5 elements.
The last example is String str = "9,,,1,,"
which gives 2 elements (9 and 1), but I would like to have 5 elements. The first element should be 9 and the fourth element should be 1 and all other should be an empty String.
How can this be done?