String[] b = a.split("|");

解决方案 »

  1.   

    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
      

  2.   

    StringTokenizer st=new StringTokenizer(a,"|");
    while(st.hasMoreTokens()){
       System.out.println(st.nextToken());
    }
      

  3.   

    String[] b = a.split("|");
    就用这个!
      

  4.   

    String[] b = a.split("|");
    就可以了
      

  5.   

    楼上zhutouzip(吃青春饭不肖子!) 的方法不错!
    很实用的!
    不过你在用这个方法的时候记得import java.util.StringTokenizer;
    要是没有这个import的话,你的程序会出错的!
      

  6.   

    他的字符串是2005$02$28$$Monday$x$y
    要求你以$为分隔符,遇到一个,就忽略它,继续输出下面的字符串,要是遇到2个连续的$$,就输出一个空格!楼主可以考虑考虑
      

  7.   

    用split就可以了不过如果中间有空的,就不好处理了
      

  8.   

    congbailing_914(静下心来学习《java编程思想》,打好基础!不玩了~!)
    你可以把你哪个帖子里的重要的帖出来看看么
      

  9.   

    用zhutouzip(吃青春饭不肖子!) 给出来的程序:
    import java.util.StringTokenizer;
    public class split{

    public static void main(String[] args)
    {
    String a = "good| |and|ss|xx";
    StringTokenizer st=new StringTokenizer(a,"|");
    while(st.hasMoreTokens()){
                    System.out.println(st.nextToken());
    } }
    }
    有没有人能给出用SPLIT方法分割的代码 谢谢
      

  10.   

    import java.util.StringTokenizer;
    public class split{

    public static void main(String[] args)
    {
    String a = "good| |and|ss|xx";
    String []result=a.split("[\\|]");
                       for(int i=;i<result.length();i++)
                           System.out.println(result[i]);
    }
    }
    split里面是一个正则表达式,因为|是特殊符号,需要转义
      

  11.   

    public class split{

    public static void main(String[] args)
    {
    String a = "good| |and|ss|xx";
    String []result=a.split("[\\|]");
                       for(int i=;i<result.length();i++)
                           System.out.println(result[i]);
    }
    }
      

  12.   

    StringTokenizer a=new StringTokenizer(a,"|")