有两方法:
1、用String的Split(str,",");
2、
字符串分割:
    public int getCount(String str,String sign){//查找某一字符串中str,特定子串s的出现次数
      if(str==null) return 0;
      StringTokenizer s=new StringTokenizer(str,sign);
      return s.countTokens();
  }
 public String[] getArray(String str,String sign){//按特定子串s为标记,将子串截成数组。
    int count=getCount(str,sign);
    int j=0;
    String[] arr=new String[count];
    for(int i=0;i<count;i++){
       if(str.indexOf(sign)!=-1){
            j     =str.indexOf(sign);
            arr[i]=str.substring(0,j);
            str   =str.substring(j+1);
        }else{
            arr[i]=str;
        }
    }
    return arr;

解决方案 »

  1.   

    java.util.StringTokenizer
    这个class可以达到你想要的效果
    但是不是一个API
    而是好几个method一起应用
      

  2.   

    StringTokenizer st = new StringTokenizer("da,f,das",",");
                  int a=st.countTokens();
                  String ss[]=new String[a];
                  int i=0;
                  while(st.hasMoreTokens()){
                    ss[i]=st.nextToken();
                     i++;
                  }
      

  3.   

    String[] ss = "123,45,7,8,9,33,4".split(",");
      

  4.   

    注:jdk1.4以上才有这个方法。
      

  5.   

    API:java.lang 
    Class String
    java.lang.Object
      |
      +-java.lang.String
    split
    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
    Since: 
    1.4 
    See Also:
    Pattern
      

  6.   

    狂晕~!
    我用的是jdkl.4,但是,我几乎不用它。
    结果,今天,看到这篇帖子,才知道,原来,居然有现成的方法~!
    而我居然笨笨的自己去写了一个方法来实现它。
    哎~!浪废了n多的脑细胞啊~!
      

  7.   

    谢谢高手们,只要
    import java.lang.String;
    就可以完成
    String[] ss = "123,45,7,8,9,33,4".split(",");
    可惜我只有20分来发放,不好意思