• Apache Commons--StringUtils字符串操作


    需要包:commons-lang.jar

    StringUtils是字符串工具类,主要方法如下:

      1、public static boolean isEmpty(CharSequence cs):判断字符串是否为“”或者null,    

        StringUtils.isEmpty(null) = true
        StringUtils.isEmpty("") = true
        StringUtils.isEmpty(" ") = false
        StringUtils.isEmpty("bob") = false
        StringUtils.isEmpty(" bob ") = false

      2、public static boolean isNotEmpty(CharSequence cs):判断字符串是否不为“”或者不为null

        StringUtils.isNotEmpty(null) = false
        StringUtils.isNotEmpty("") = false
        StringUtils.isNotEmpty(" ") = true
        StringUtils.isNotEmpty("bob") = true
        StringUtils.isNotEmpty(" bob ") = true

      3、public static boolean isAnyEmpty(CharSequence... css):任意一个参数为空的话,返回true,如果这些参数都不为空的话返回false 

        StringUtils.isAnyEmpty(null) = true
        StringUtils.isAnyEmpty(null, "foo") = true
        StringUtils.isAnyEmpty("", "bar") = true
        StringUtils.isAnyEmpty("bob", "") = true
        StringUtils.isAnyEmpty(" bob ", null) = true
        StringUtils.isAnyEmpty(" ", "bar") = false
        StringUtils.isAnyEmpty("foo", "bar") = false

      4、public static boolean isNoneEmpty(CharSequence... css):任意一个参数是空,返回false,所有参数都不为空,返回true   

        StringUtils.isNoneEmpty(null) = false
        StringUtils.isNoneEmpty(null, "foo") = false
        StringUtils.isNoneEmpty("", "bar") = false
        StringUtils.isNoneEmpty("bob", "") = false
        StringUtils.isNoneEmpty(" bob ", null) = false
        StringUtils.isNoneEmpty(" ", "bar") = true
        StringUtils.isNoneEmpty("foo", "bar") = true

      5、public static boolean isBlank(CharSequence cs):判断字符对象是不是空字符串   

        StringUtils.isBlank(null) = true
        StringUtils.isBlank("") = true
        StringUtils.isBlank(" ") = true
        StringUtils.isBlank("bob") = false
        StringUtils.isBlank(" bob ") = false

      6、public static boolean isNotBlank(CharSequence cs):判断字符对象是不是不为空字符串

      7、public static boolean isAnyBlank(CharSequence... css):判断字符串是不是空字符串,都是空字符串就返回true,否则返回false

      8、public static boolean isNoneBlank(CharSequence... css):判断字符串是不是不是空字符串,全部不是空字符串就返回true,否则返回false 

      9、public static String trim(String str):去除字符串首尾的空格

      10、public static boolean equals(CharSequence cs1, CharSequence cs2):判断字符串是否相等

      11、public static boolean equalsIgnoreCase(CharSequence str1, CharSequence str2):字符串比较,忽略大小写

      12、public static int indexOf(CharSequence seq, int searchChar):返回字符串首次出现的位置索引

      13、public static int ordinalIndexOf(CharSequence str, CharSequence searchStr, int ordinal):判断字符串在另一个字符串第几次出现的位置索引

      14、public static int lastIndexOf(CharSequence seq,int searchChar):字符在字符串中最后一次出现的位置索引

      15、public static int lastOrdinalIndexOf(CharSequence str,CharSequence searchStr, int ordinal):判断字符在字符串倒数第几次出现的位置索引

      16、public static boolean contains(CharSequence seq, int searchChar):判断是字符是否在另一个字符串中

      17、public static String substring(String str,int start):字符串截取

      18、public static String left(String str,int len):字符串左边的多少个字符

        public static String right(String str, int len):字符串右边的多少个字符

        

      

  • 相关阅读:
    tomcat虚拟目录配置
    关于JS闭包
    数据列表里结合负边距做间隔线的技巧需注意的小细节
    前端优化技巧笔记
    浏览器工作原理相关笔记
    工作小心得(关于绝对定位元素)
    关于定位和溢出处理的一些小经历
    关于定位和z-index的一些小经历
    fullpage实现(-)
    移动端布局-实例
  • 原文地址:https://www.cnblogs.com/-scl/p/7679241.html
Copyright © 2020-2023  润新知