<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    posts - 3, comments - 15, trackbacks - 0, articles - 26
      BlogJava :: 首頁(yè) :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理

    String的靜態(tài)方法split(String a)有點(diǎn)問(wèn)題,列如
    String a0 = "|we|r|";
    String[] b0 = a0.split("|");
    b0不會(huì)得到預(yù)期的數(shù)組,而是{"|","w","e","r","|"}.

    于是寫(xiě)了一個(gè)類(lèi)代替這個(gè)方法
    如下
    public class Strings {
     public static  Collection seperateBy(String target,String seperate) {
          if (target==null||seperate==null||target.equals("")){
           return new ArrayList();
          }
          Collection collection = new ArrayList();
          int num = target.indexOf(seperate);
          if (num!=-1){
           if(num==0){
            target = target.substring(1,target.length());
                Collection here = seperateBy(target,seperate);
                for(Iterator iterator1 = here.iterator();iterator1.hasNext();){
                 collection.add(iterator1.next());
                }
                return collection;
             }
           else if(num == target.length()-1){
            collection.add(target.substring(0,target.length()-1));
            return collection;
           }
           else
           {
            collection.add(target.substring(0,num));
            target = target.substring(num+1,target.length());
            Collection here = seperateBy(target,seperate);
               for(Iterator iterator1 = here.iterator();iterator1.hasNext();){
                collection.add(iterator1.next());
               }
               return collection;
           }
          }
          else collection.add(target);
          return  collection;
         }
    /*測(cè)試
     public static  void main(String[] args) {
      Collection a1 = Strings.seperateBy("|aaa|aa","|");
      Collection a2 =Strings.seperateBy("|aaa|aa|","|");
      Collection a3 =Strings.seperateBy("aaa|aa","|");
      Collection a4 =Strings.seperateBy("aaaaa","|");
      Collection a5 =Strings.seperateBy("|aaa|aa","|");
      Collection a6 =Strings.seperateBy("||||","|");
      Collection a7 =Strings.seperateBy("","|");
     }*/
    }



    正則表達(dá)式問(wèn)題

    正確寫(xiě)法String a0 = "|we|r|";
    String[] b0 = a0.split("\\|");

    主站蜘蛛池模板: 91成人免费观看| 亚洲成人在线免费观看| 美女被免费视频网站a国产| 国产一级一毛免费黄片| 亚洲精品久久无码| 亚洲精彩视频在线观看| 国产∨亚洲V天堂无码久久久| 卡1卡2卡3卡4卡5免费视频| 成人午夜免费福利视频| 免费日本一区二区| 成人妇女免费播放久久久| 男女啪啪免费体验区| 亚洲国产精品美女久久久久| 亚洲一卡二卡三卡| 亚洲好看的理论片电影| 亚洲国产精品成人精品无码区在线| 亚洲精品黄色视频在线观看免费资源 | 国产在亚洲线视频观看| 亚洲中文字幕无码中文字| 亚洲国产成人资源在线软件| 久久亚洲国产成人精品性色| 亚洲国产精品自在线一区二区 | 久久一区二区三区免费| 亚洲阿v天堂在线2017免费| 暖暖免费中文在线日本| 黄页网址大全免费观看12网站| 亚洲AV香蕉一区区二区三区| 亚洲精品无码久久久久秋霞| 亚洲熟妇无码一区二区三区| 亚洲国产精品无码中文lv| 亚洲无吗在线视频| 中文字幕亚洲情99在线| 亚洲综合av一区二区三区不卡| 亚洲成_人网站图片| 无码亚洲成a人在线观看| 久久久久亚洲精品无码网址色欲| 亚洲国产区男人本色| 国产精品亚洲片在线花蝴蝶| 免费看黄网站在线看| 久久精品无码免费不卡| 免费无码又爽又刺激一高潮|