class EngineUtil {

    public static String[] split(final String str, final char delim, final int maxTokens) {
        int max = maxTokens;
        List<String> result = new ArrayList<String>(max);
        if (max == 0) {
            max = -1;
        }

        int curr = -1;
        int prev = 0;
        while (true) {
            ++curr;
            if (curr == str.length()) {
                result.add(str.substring(prev, str.length()));
                --max;
                break;
            }
            if (str.charAt(curr) == delim) {
                result.add(str.substring(prev, curr));
                --max;
                prev = curr + 1;
            }

            if (max == 0) {
                break;
            }
        }
        return result.toArray(new String[result.size()]);
    }

    private  EngineUtil();

}