public static String[] split(String string,char c){
  if (countMatches(string,c) <= 0)   return new String[]{string};
  String s=string + c;
  String[] sa=new String[countMatches(string,c) + 1];
  StringBuilder sb=new StringBuilder();
  char[] ca=s.toCharArray();
  int n=0, x;
  for (x=0; x < ca.length; x++) {
    if (ca[x] == c) {
      sa[n]=sb.toString();
      sb=new StringBuilder();
      n++;
    }
 else {
      sb.append(ca[x]);
    }
  }
  return sa;
}

public static String [ ] split ( String string , char c ) { if ( countMatches ( string , c ) <= 0 ) return new String [ ] { string } ; String s = string + c ; String [ ] sa = new String [ countMatches ( string , c ) + 1 ] ; StringBuilder sb = new StringBuilder ( ) ; char [ ] ca = s . toCharArray ( ) ; int n = 0 , x ; for ( x = 0 ; x < ca . length ; x ++ ) { if ( ca [ x ] == c ) { sa [ n ] = sb . toString ( ) ; sb = new StringBuilder ( ) ; n ++ ; } else { sb . append ( ca [ x ] ) ; } } return sa ; }
splits the string every time the given character has been found
