2020-03-25

Spring - StringUtils split example

split(String toSplit, String delimiter)

Split a String at the first occurrence of the delimiter.

Method:

public static String[] split(@Nullable String toSplit, @Nullable String delimiter)


Example:

String[] list = StringUtils.split("Hello1, Hello2", ",");


Split a String at the first occurrence of the delimiter. Does not include the delimiter in the result.

Parameters:

toSplit - the string to split (potentially null or empty)
delimiter - to split the string up with (potentially null or empty)

Returns:

a two element array with index 0 being before the delimiter, and index 1 being after the delimiter (neither element includes the delimiter); or null if the delimiter wasn't found in the given input String

No comments:

Post a Comment