应该没什么问题啊,大部分情况,不要怀疑sun的api

解决方案 »

  1.   

    public static String replaceAll(String str, String old, String news)
        {
            if(str == null)
                return str;
            int begin = 0;
            int idx = 0;
            int len = old.length();
            StringBuffer buf = new StringBuffer();
            while((idx = str.indexOf(old, begin)) >= 0) 
            {
                buf.append(str.substring(begin, idx));
                buf.append(news);
                begin = idx + len;
            }
            return new String(buf.append(str.substring(begin)));
        }
      

  2.   

    楼上的大哥,写的方法不错,不过人家可能说的是jdk1,4里面的replaceall
      

  3.   

    问题已经解决,提示,要用到StringBuffer