public String[] split(String regex)Splits this string around matches of the given regular expression. 
This method works as if by invoking the two-argument split method with the given expression and a limit argument of zero. Trailing empty strings are therefore not included in the resulting array. The string "boo:and:foo", for example, yields the following results with these expressions: Regex     Result 
: { "boo", "and", "foo" } 
o { "b", "", ":and:f" } 
Parameters:
regex - the delimiting regular expression 
Returns:
the array of strings computed by splitting this string around matches of the given regular expression 
Throws: 
PatternSyntaxException - if the regular expression's syntax is invalid 
NullPointerException - if regex is null

解决方案 »

  1.   

    public String[] split(String regex) 是 String 的一个方法,例子:class Test
    {
    public static void main(String[] args) 
    {
    String[] st = ("aaaaa;bbbbb;cccccc;dddddd;").split(";");

    for(int i=0; i<st.length; i++){
    System.out.println(st[i]);
    }
    }
    }运行结果:
    ---------- Run ----------
    aaaaa
    bbbbb
    cccccc
    ddddddOutput completed (0 sec consumed) - Normal Termination不知道这样回答是否解决了你的问题?
      

  2.   

    呵呵,谢谢不过我还是用不了。
    我用的是j2me开发包,里面的String没有split方法。
      

  3.   

    String sTemp = "aaaaa;bbbbb;cccccc;dddddd;";
        int nItem = 0;
        String[] sValue = new String[4];
        for(int n = 0; n < 4; n++)
          sValue[n] = "";    for(int i = 0; i < sTemp.length(); i++)
        {
          if(sTemp.charAt(i) == ';')
          {
             nItem ++;
             continue;
          }
          sValue[nItem] += sTemp.charAt(i);
        }
        for(int j = 0; j < sValue.length; j++)
          System.out.println(sValue[j]);