How do I split strings in J2ME?

后端 未结 8 640
無奈伤痛
無奈伤痛 2020-12-01 14:32

How do I split strings in J2ME in an effective way?

There is a StringTokenizer or String.split(String regex) in the standard edition (J2SE), but they are absent in t

8条回答
  •  旧巷少年郎
    2020-12-01 15:13

    public static Vector splitDelimiter(String text, char delimiter) {
        Vector splittedString = null;
        String text1 = "";
    
        if (text != null) {
            splittedString = new Vector();
            for (int i = 0; i < text.length(); i++) {
                if (text.charAt(i) == delimiter) {
                    splittedString.addElement(text1);
                    text1 = "";
                } else {
                    text1 += text.charAt(i);
                    // if(i==text.length()-1){
                    // splittedString.addElement(text1);
                    // }
                }
            }
            splittedString.addElement(text1);
        }
        return s
         }
    

    You can use this method for splitting a delimiter.

提交回复
热议问题