Reputation: 938
I have a project in Java, which collects data from a Linux machine and gets output like this:
SwapCached: 0 kB
I need to split this sentence into this words:
SwapCached,0
I know how to split by single characters, but don't know how to split with multiple words(like kB) and multiple spaces together.
EDIT: I tried this one but it didn't clear the spaces.
bolunmus[i]=line.split(":|\\ +|\\ |kB");
Upvotes: 0
Views: 1109
Reputation: 9457
It doesn't clear spaces, because you didn't tell it to:
bolunmus[i]=line.split(" *(:|kB) *");
Upvotes: 3