org.apache.commons.lang.StringUtils中方法的操作对象是java.lang.String类型的对象,是JDK提供的String类型操作方法的补充,并且是null安全的(即如果输入参数String为null则不会抛出NullPointerException,而是做了相应处理,例如,如果输入为null则返回也是null等,具体可以查看源代码)。

除了构造器,StringUtils中一共有130多个方法,并且都是static的,

所以我们可以这样调用StringUtils.xxx()。

下面分别对一些常用方法做简要介绍:

1. public static boolean isEmpty(String str)

判断某字符串是否为空,为空的标准是str == null 或 str.length() == 0

下面是示例:

StringUtils.isEmpty(null)          = true

StringUtils.isEmpty("")       = true

StringUtils.isEmpty(" ")      = false

StringUtils.isEmpty("        ")     = false

StringUtils.isEmpty("bob")       = false

StringUtils.isEmpty(" bob ") = false

2. public static boolean isNotEmpty(String str)

判断某字符串是否非空,等于!isEmpty(String str)

下面是示例:

StringUtils.isNotEmpty(null)        = false

StringUtils.isNotEmpty("")           = false

StringUtils.isNotEmpty(" ")      = true

StringUtils.isNotEmpty("         ")    = true

StringUtils.isNotEmpty("bob")   = true

StringUtils.isNotEmpty(" bob ")   = true

StringUtils方法的更多相关文章

  1. StringUtils方法介绍

    引用StringUtils方法全集介绍 C标准中空白字符有:空格(‘ ’).换页(‘\f’).换行(‘\n’).回车(‘\r’).水平制表符(‘\t’).垂直制表符(‘\v’)六个.

  2. StringUtils 方法全集

    最近做项目需要,经常需要最字符串进行拆分等操作,经搜索和研究,发现了一篇StringUtils方法全集的文章,不错,特贴出来,以后用: 参考:http://blog.sina.com.cn/s/blo ...

  3. JAVA StringUtils方法全集

    StringUtils方法全集 org.apache.commons.lang.StringUtils中方法的操作对象是java.lang.String类型的对象,是JDK提供 的String类型操作 ...

  4. StringUtils方法全集

    org.apache.commons.lang.StringUtils中方法的操作对象是java.lang.String类型的对象,是JDK提供的String类型操作方法的补充,并且是null安全的( ...

  5. [转]StringUtils方法

    摘自http://blog.sina.com.cn/s/blog_4550f3ca0100qrsd.html org.apache.commons.lang.StringUtils中方法的操作对象是j ...

  6. 【转载】StringUtils方法介绍

    org.apache.commons.lang.StringUtils中方法的操作对象是java.lang.String类型的对象,是JDK提供 的String类型操作方法的补充,并且是null安全的 ...

  7. StringUtils方法全集(转)

    JAVA对于字符串的操作真是太强大了!!! 在 commons-lang3-3.2.jar 包里 org.apache.commons.lang.StringUtils中方法的操作对象是java.la ...

  8. StringUtils类常用的方法讲解

    StringUtils 方法的操作对象是 Java.lang.String 类型的对象,是 JDK 提供的 String 类型操作方法的补充,并且是 null 安全的(即如果输入参数 String 为 ...

  9. StringUtils类API及使用方法详解

    StringUtils类API及使用方法详解 StringUtils方法概览 判空函数 1)StringUtils.isEmpty(String str) 2)StringUtils.isNotEmp ...

随机推荐

  1. C语言中 单引号与双引号的区别

    在C语言中,字符用单引号,字符串用双引号.在c1='a';中,'a'是字符常量,必须用单引号."a"表示字符串,包含两个字符,一个是'a',一个是'\0'. 用数组来存储字符串. ...

  2. web储存用户信息

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8&quo ...

  3. Docker Daemon 连接方式详解

    前言 在 Docker 常用详解指令 一文中粗粗提了一下, Docker 是分为客户端和服务端两部分的, 本文将介绍客户端是如何连接服务端的. 连接方式 1. UNIX域套接字 默认就是这种方式, 会 ...

  4. pat 团体天梯赛 L3-015. 球队“食物链”

    L3-015. 球队“食物链” 时间限制 1000 ms 内存限制 262144 kB 代码长度限制 8000 B 判题程序 Standard 作者 李文新(北京大学) 某国的足球联赛中有N支参赛球队 ...

  5. FckEditor2.65使用范例源码

    原文发布时间为:2009-10-12 -- 来源于本人的百度文章 [由搬家工具导入] 下载地址:http://www.xmaspx.com/Services/FileAttachment.ashx?A ...

  6. 学习 表单验证插件validate

    <!doctype html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  7. [LeetCode] Valid Number 确认是否为数值

    Validate if a given string is numeric. Some examples:"0" => true" 0.1 " => ...

  8. [LeetCode] Rotate List 单项链表旋转

    Given a list, rotate the list to the right by k places, where k is non-negative. For example:Given 1 ...

  9. bq25890 ship mode

    Precondition 此是以 evb board 來做實驗的. 沒接 Vbus 僅接 i2c ,仍可以 讀寫 i2c register,但是 adc 似乎不能 working, evb board ...

  10. C#图片转成流,流转成图片,字节转图片,图片转字节的方法

    图片转成流 Bitmap b = new Bitmap(Server.MapPath(ppath)); Stream ms = new MemoryStream(); b.Save(ms, Syste ...