MCPcopy Create free account
hub / github.com/jwtk/jjwt / split

Method split

api/src/main/java/io/jsonwebtoken/lang/Strings.java:1055–1066  ·  view source on GitHub ↗

Split a String at the first occurrence of the delimiter. Does not include the delimiter in the result. @param toSplit the string to split @param delimiter to split the string up with @return a two element array with index 0 being before the delimiter, and index 1 being after the delimiter (neithe

(String toSplit, String delimiter)

Source from the content-addressed store, hash-verified

1053 * or <code>null</code> if the delimiter wasn't found in the given input String
1054 */
1055 public static String[] split(String toSplit, String delimiter) {
1056 if (!hasLength(toSplit) || !hasLength(delimiter)) {
1057 return null;
1058 }
1059 int offset = toSplit.indexOf(delimiter);
1060 if (offset < 0) {
1061 return null;
1062 }
1063 String beforeDelimiter = toSplit.substring(0, offset);
1064 String afterDelimiter = toSplit.substring(offset + delimiter.length());
1065 return new String[]{beforeDelimiter, afterDelimiter};
1066 }
1067
1068 /**
1069 * Take an array Strings and split each element based on the given delimiter.

Callers 1

Calls 3

hasLengthMethod · 0.95
indexOfMethod · 0.80
lengthMethod · 0.45

Tested by

no test coverage detected