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

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

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

    鷹翔宇空

    學習和生活

    BlogJava 首頁 新隨筆 聯(lián)系 聚合 管理
      110 Posts :: 141 Stories :: 315 Comments :: 1 Trackbacks
    引自:http://www.tkk7.com/zyb9114/articles/27748.html

    檢查字符串是否為空或null或僅僅包含空格
    ? String test = "";
    ? String test1=" ";
    ? String test2 = "\n\n\t";
    ? String test3 = null;
    ? System.out.println( "test blank? " + StringUtils.isBlank( test ) );
    ? System.out.println( "test1 blank? " + StringUtils.isBlank( test1 ) );
    ? System.out.println( "test2 blank? " + StringUtils.isBlank( test2 ) );
    ? System.out.println( "test3 blank? " + StringUtils.isBlank( test3 ) );
    ? 運行結果:
    ? test blank? true
    ? test1 blank? true
    ? test2 blank? true
    ? test3 blank? true
    ? 相對應的還有一個StringUtils.isNotBlank(String str)
    ? StringUtils.isEmpty(String str)則檢查字符串是否為空或null(不檢查是否僅僅包含空格)
    ?
    ? 分解字符串
    ? StringUtils.split(null, *, *)??????????? = null
    ? StringUtils.split("", *, *)????????????? = []
    ? StringUtils.split("ab de fg", null, 0)?? = ["ab", "cd", "ef"]
    ? StringUtils.split("ab?? de fg", null, 0) = ["ab", "cd", "ef"]
    ? StringUtils.split("ab:cd:ef", ":", 0)??? = ["ab", "cd", "ef"]
    ? StringUtils.split("ab:cd:ef", ":", 1)??? = ["ab:cd:ef"]
    ? StringUtils.split("ab:cd:ef", ":", 2)??? = ["ab", "cd:ef"]
    ? StringUtils.split(String str,String separatorChars,int max) str為null時返回null
    ? separatorChars為null時默認為按空格分解,max為0或負數(shù)時分解沒有限制,max為1時返回整個字符串,max為分解成的個數(shù)(大于實際則無效)
    ?
    ? 去除字符串前后指定的字符
    ? StringUtils.strip(null, *)????????? = null
    ? StringUtils.strip("", *)??????????? = ""
    ? StringUtils.strip("abc", null)????? = "abc"
    ? StringUtils.strip(" abc ", null)??? = "abc"
    ? StringUtils.strip("? abcyx", "xyz") = "? abc"
    ? StringUtils.strip(String str,String stripChars) str為null時返回null,stripChars為null時默認為空格

    ? 創(chuàng)建醒目的Header(調(diào)試時用)
    ? public String createHeader( String title ) {
    ??? int width = 30;
    ??? String stars = StringUtils.repeat( "*", width);
    ??? String centered = StringUtils.center( title, width, "*" );
    ??? String heading = StringUtils.join(new Object[]{stars, centered, stars}, "\n");
    ??? return heading;
    ? }
    ? 調(diào)用createHeader("TEST")的輸出結果:
    ? ******************************
    ? ************ TEST ************
    ? ******************************

    ? 字符的全部反轉(zhuǎn)及以單個詞為單位的反轉(zhuǎn)
    ? String original = "In time, I grew tired of his babbling nonsense.";
    ? StringUtils.reverse( original )?? = ".esnesnon gnilbbab sih fo derit werg I ,emit nI"
    ? 以單個詞為單位的反轉(zhuǎn)
    ? public Sentence reverseSentence(String sentence) {
    ??? String reversed = StringUtils.chomp( sentence, "." );
    ??? reversed = StringUtils.reverseDelimited( reversed, ' ' );
    ??? reversed = reversed + ".";
    ??? return reversed;
    ? }
    ? String sentence = "I am Susan."
    ? reverseSentence( sentence ) )?? = "Susan am I."

    ? 檢查字符串是否僅僅包含數(shù)字、字母或數(shù)字和字母的混合
    ? String test1 = "ORANGE";
    ? String test2 = "ICE9";
    ? String test3 = "ICE CREAM";
    ? String test4 = "820B Judson Avenue";
    ? String test5 = "1976";
    ? 結果:
    ? boolean t1val = StringUtils.isAlpha( test1 ); // returns true
    ? boolean t2val = StringUtils.isAlphanumeric( test2 ); // returns true
    ? boolean t3val = StringUtils.isAlphaSpace( test3 ); // returns true
    ? boolean t4val = StringUtils.isAlphanumericSpace( test4 ); // returns true
    ? boolean t5val = StringUtils.isNumeric( test5 ); // returns true

    posted on 2006-01-13 12:47 TrampEagle 閱讀(194) 評論(0)  編輯  收藏 所屬分類: java
    主站蜘蛛池模板: 亚洲一区二区在线免费观看| 亚洲邪恶天堂影院在线观看| 国产v亚洲v天堂a无| 久艹视频在线免费观看| 中文字幕不卡亚洲| 青柠影视在线观看免费高清| 日韩亚洲变态另类中文| 成人国产精品免费视频 | 永久免费bbbbbb视频| 亚洲中文字幕无码mv| 无码日韩人妻AV一区免费l| 久久香蕉国产线看免费| 久久国产亚洲电影天堂| 99免费观看视频| 亚洲精品无码专区久久同性男| 亚洲综合校园春色| 成人网站免费观看| 丰满亚洲大尺度无码无码专线| 美丽的姑娘免费观看在线播放| 亚洲日本乱码一区二区在线二产线 | 黄瓜视频影院在线观看免费| 亚洲精品成人无限看| 美女无遮挡免费视频网站| 国产精品亚洲精品日韩已方| 亚洲av无码有乱码在线观看| 免费jjzz在在线播放国产| 中文字幕免费在线看| 亚洲精品在线网站| 亚洲黄色免费电影| 亚洲欧美日韩中文字幕在线一区| 国产精品二区三区免费播放心 | 亚洲国产精品人人做人人爱| 免费看搞黄视频网站| 99999久久久久久亚洲| 全亚洲最新黄色特级网站| 亚洲爆乳无码专区www| 亚洲色偷偷狠狠综合网| 99久久99久久精品免费观看| 亚洲AV无码资源在线观看| 国产亚洲精品a在线观看app| 希望影院高清免费观看视频|