Java String split()
There are situation where strings contain multiple pieces of information , then we will need to split the string to extract the individual pieces. Strings in Java can be split using the split() method of the String class.
regex : regular expression to be applied on string.
Returns: array of strings
Java String split() is based on regex expression, a special attention is needed with some characters which have a special meaning in a regex expression.
Spliting string with limit
You can set a limit the output strings.
There are situation that several characters being used as delimiters.
How to split a String by space
Java String.split() method is based upon regular expressions. So provide "\\s+" as split parameter.