MCPcopy Create free account
hub / github.com/curtcox/JLHTTP / split

Method split

src/main/java/net/freeutils/httpserver/HTTPServer.java:2531–2547  ·  view source on GitHub ↗

Splits the given string into its constituent non-empty trimmed elements, which are delimited by any of the given delimiter characters. This is a more direct and efficient implementation than using a regex (e.g. String.split()), trimming the elements and removing empty ones. @param str the string to

(String str, String delimiters, int limit)

Source from the content-addressed store, hash-verified

2529 * @return the non-empty elements in the string, or an empty array
2530 */
2531 public static String[] split(String str, String delimiters, int limit) {
2532 if (str == null)
2533 return new String[0];
2534 Collection<String> elements = new ArrayList<String>();
2535 int len = str.length();
2536 int start = 0;
2537 int end;
2538 while (start < len) {
2539 for (end = --limit == 0 ? len : start;
2540 end < len && delimiters.indexOf(str.charAt(end)) < 0; end++);
2541 String element = str.substring(start, end).trim();
2542 if (element.length() > 0)
2543 elements.add(element);
2544 start = end + 1;
2545 }
2546 return elements.toArray(new String[elements.size()]);
2547 }
2548
2549 /**
2550 * Returns a string constructed by joining the string representations of the

Callers 5

addContentTypesMethod · 0.95
parseParamsListMethod · 0.95
splitElementsMethod · 0.95
getParamsMethod · 0.80
readRequestLineMethod · 0.80

Calls 2

addMethod · 0.80
sizeMethod · 0.80

Tested by

no test coverage detected