The Guava library has a class Splitter. I do not really understand why something does not work for me. There is a code:
private static final Splitter splitter = Splitter.on(' ').limit(1); public static void main(String[] args) { String text = "text text"; splitter.split(text).forEach(System.out::println); } Conclusion: text text
According to my logic, the splitter had to find the first space and stop, but why he does not even find it. If you set the unit to 2, then the output will be:
text text The question is, what am I doing wrong? It is necessary for me that the transmitted string in the splitter be divided into spaces only once and the program did not waste time dividing the rest of the string.