Java String Split splitStr(String str, int toCount)

Here you can find the source of splitStr(String str, int toCount)

Description

split Str

License

LGPL

Declaration

public static ArrayList splitStr(String str, int toCount) 

Method Source Code

//package com.java2s;

import java.util.ArrayList;

public class Main {

    public static ArrayList splitStr(String str, int toCount) {
        int reInt = 0;
        if (str == null)
            return null;
        char[] tempChar = str.toCharArray();
        int totalChars = tempChar.length;
        ArrayList result = new ArrayList();
        int totalBytes = 0;
        int i = 0;
        while (totalBytes < str.getBytes().length) {
            StringBuffer reStr = new StringBuffer();
            int stepInt = 0;
            for (int kk = 0; (kk < tempChar.length && toCount > reInt); kk++) {
                if ((tempChar[kk] >= 0x0021) && (tempChar[kk] <= 0x007e)) {
                    reInt += 1;//  www .ja  va 2 s .c  o  m
                } else {
                    reInt += 2;
                }

                reStr.append(tempChar[kk]);
                i++;
                stepInt++;
            }
            char[] tmp = new char[totalChars - i];
            for (int j = 0; j < tmp.length; j++) {
                tmp[j] = tempChar[stepInt + j];
            }
            tempChar = tmp;
            totalBytes += reInt;
            reInt = 0;
            result.add(reStr.toString());
        }

        return result;
    }
}

Related

  1. splitSimple(String split, String s)
  2. splitSimpleQueries(String queryString)
  3. splitSQL(List list, String sql)
  4. splitSQLColumns(String sql)
  5. splitStep(String step)
  6. splitString(String bigString, String splitter)
  7. splitString(String hexString, int partSize)
  8. splitString(String s)
  9. splitString(String s)