| Total Complexity | 6 |
| Total Lines | 23 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | package de.pewpewproject.lasertag.common.util; |
||
| 8 | public class StringUtil { |
||
| 9 | public static boolean stringEndsWithList(String path, String[] endings) { |
||
| 10 | for (var ending : endings) { |
||
| 11 | if (path.endsWith(ending)) { |
||
| 12 | return true; |
||
| 13 | } |
||
| 14 | } |
||
| 15 | |||
| 16 | return false; |
||
| 17 | } |
||
| 18 | |||
| 19 | public static String[] splitAtNthChar(String string, char character, int n) { |
||
| 20 | var idx = -1; |
||
| 21 | |||
| 22 | for(int i = 0; i < n; i++) { |
||
| 23 | if (idx + 1 >= string.length()) { |
||
| 24 | return new String[] { string, "" }; |
||
| 25 | } |
||
| 26 | |||
| 27 | idx = string.indexOf(character, idx + 1); |
||
| 28 | } |
||
| 29 | |||
| 30 | return new String[] {string.substring(0, idx), string.substring(idx + 1)}; |
||
| 31 | } |
||
| 33 |