How can a split a line with multiple spaces?

How can a split a line with multiple spaces?

I’m having trouble separating a line that has a different amount in spaces in it so that I can store them.

Example line (there are multiple lines in the file) :


1 9 10 5 24

I’m Trying


 val reader = BufferedReader(FileReader(fileName, Charsets.UTF_8)) reader.lines().forEach { val list = it.split("\s+"); //a = list[0].toInt(); //b = list[1].toInt(); //continue for every element of the list.. }

submitted by /u/One-Bug5148
[link] [comments]