I am willing to read a series of number from one line like below in Java:
1 80,982 163,8164 170,2620
So eventually I want the result array [1, 80, 982, 163, 8164, 170, 2620]
I am thinking about using scanner, but not clear how to implement it in a neat way, can I ask some tips please?
Thanks for reading!
If it were me, I'd read one line using BufferedReader
and then simply use
String[] values = line.split("[, ]");
I usually find Scanner
untidy and overkill.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With