分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 代码编程

Apache Commons--StringUtils

发布时间:2023-09-06 01:18责任编辑:蔡小小关键词:暂无标签

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):字符串右边的多少个字符

    

  

Apache Commons--StringUtils

原文地址:http://www.cnblogs.com/-scl/p/7679241.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved