Java - parse lines

file, java, parsing

Solution

You could split by `\s+` and accessing the last cell of the returned array.

for (String line : lines) {
    String[] data = line.split("\\s+");
    String lastEntry = data[data.length - 1];
    // lastEntry contains what you're looking for
}

Problem

What is the best practice for parsing these lines from a file? ``` files txt 50 // first gab are spaces, the second is tabulator files bmp 9979 files all 2063 score scr 656 index ind 0.0779 index ind 0.0213 ``` I need to get just values (`50, 9979`, etc.) to be able to save them to CSV file (but this is not part of this question).

Original source