Java String Split by Char Split(String Str, char splitchar)

Here you can find the source of Split(String Str, char splitchar)

Description

??????

License

LGPL

Parameter

Parameter Description
Str String ?????
splitchar char ??????

Return

ArrayList

Declaration

public static ArrayList Split(String Str, char splitchar) 

Method Source Code

//package com.java2s;

import java.util.ArrayList;

public class Main {
    /**// w ww. ja  v  a2 s  .c o m
     * ??????
     *
     * @param Str
     *            String ?????
     * @param splitchar
     *            char ??????
     * @return ArrayList
     */
    public static ArrayList Split(String Str, char splitchar) {
        if (Str != null) {
            ArrayList ret = new ArrayList();
            StringBuffer tmpBuffer = new StringBuffer();
            for (int i = 0; i < Str.length(); i++) {
                if (Str.charAt(i) != splitchar)
                    tmpBuffer.append(Str.charAt(i));
                else {
                    ret.add(tmpBuffer.toString());
                    tmpBuffer.delete(0, tmpBuffer.length());
                }
            }
            if (tmpBuffer.length() > 0) {
                ret.add(tmpBuffer.toString());
                tmpBuffer.delete(0, tmpBuffer.length());
            }

            return ret;

        } else
            return new ArrayList();
    }
}

Related

  1. split(String str, char cha)
  2. split(String str, char deli)
  3. split(String str, char sep)
  4. split(String str, char splitChar)
  5. split(String str, char splitChar)
  6. split(String string, char c)
  7. split(String string, char character)
  8. split(String toSplit, char splitChar, boolean trim)
  9. split(String val, char ch)