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)
| 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. |
no test coverage detected