Here you can find the source of tokenize(final String s)
public static List<String> tokenize(final String s)
//package com.java2s; /*/*from w w w. j a va 2s .c o m*/ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You should have received a copy of the license along with this library. * You may also obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0. */ import java.util.ArrayList; import java.util.List; public class Main { public static List<String> tokenize(final String s) { return tokenize(" \t\n\r\u0085\u2028", s); } public static List<String> tokenize(final String delims, final String s) { final List<String> ret = new ArrayList<String>(); final int len = s.length(); int start = -1; for (int i = 0; i < len; ++i) { final char c = s.charAt(i); if (delims.indexOf(c) >= 0) { if (start >= 0) { ret.add(s.substring(start, i)); start = -1; } continue; } if (start < 0) { start = i; } } if (start >= 0) { ret.add(s.substring(start, len)); } return ret; } }