code: public static String[] explode(String str, int ch, boolean respectEmpty)
     {
        if (str == null || str.length() == 0)
        {
           return new String[0];
        }
  
        ArrayList strings = new ArrayList();
        int pos;
        int lastpos = 0;
  
        // add snipples
        while ((pos = str.indexOf(ch, lastpos)) >= 0)
        {
           if (pos - lastpos > 0 || respectEmpty)
           {
              strings.add(str.substring(lastpos, pos));
           }
           lastpos = pos + 1;
        }
        // add rest
        if (lastpos < str.length())
        {
           strings.add(str.substring(lastpos));
        }
        else if (respectEmpty && lastpos == str.length())
        {
           strings.add("");
        }
  
        // return stringarray
        return (String[])strings.toArray(new String[strings.size()]);
     }
docs: returns an array of strings decomposed of the original string, split at every occurance of
  'ch'.
  
  @param str
  the string to decompose
  @param ch
  the character to use a split pattern
  @param respectEmpty
  if <code>true</code>, empty elements are generated
  @return an array of strings