辅助字符串处理类:org.apache.commons.lang3.StringUtils
api 地址:http://commons.apache.org/proper/commons-lang/apidocs/index.html?index-all.html
StringUtils 常用方法:
| 方法 | 作用 |
|---|---|
| isBlank | 判断某字符串是否为空、长度为0、由空白符(whitespace) 构成。isBlank(" ")为true。多数情况用 isBlank |
| isEmpty | 判断某字符串是否为空,为空的标准是 strnull 或 str.length()0。isEmpty(" ")为false |
| trim | 去掉字符串两端的控制符(control characters, char <= 32)。如果为null或"",则返回null |
| strip | 去掉字符串两端的空白符(whitespace)。如果输入为null则返回null |
- StringUtils 说明:
Operations on String that are null safe.
IsEmpty/IsBlank - checks if a String contains text
Trim/Strip - removes leading and trailing whitespace
Equals/Compare - compares two strings null-safe
startsWith - check if a String starts with a prefix null-safe
endsWith - check if a String ends with a suffix null-safe
IndexOf/LastIndexOf/Contains - null-safe index-of checks
IndexOfAny/LastIndexOfAny/IndexOfAnyBut/LastIndexOfAnyBut - index-of any of a set of Strings
ContainsOnly/ContainsNone/ContainsAny - does String contains only/none/any of these characters
Substring/Left/Right/Mid - null-safe substring extractions
SubstringBefore/SubstringAfter/SubstringBetween - substring extraction relative to other strings
Split/Join - splits a String into an array of substrings and vice versa
Remove/Delete - removes part of a String
Replace/Overlay - Searches a String and replaces one String with another
Chomp/Chop - removes the last part of a String
AppendIfMissing - appends a suffix to the end of the String if not present
PrependIfMissing - prepends a prefix to the start of the String if not present
LeftPad/RightPad/Center/Repeat - pads a String
UpperCase/LowerCase/SwapCase/Capitalize/Uncapitalize - changes the case of a String
CountMatches - counts the number of occurrences of one String in another
IsAlpha/IsNumeric/IsWhitespace/IsAsciiPrintable - checks the characters in a String
DefaultString - protects against a null input String
Rotate - rotate (circular shift) a String
Reverse/ReverseDelimited - reverses a String
Abbreviate - abbreviates a string using ellipsis or another given String
Difference - compares Strings and reports on their differences
LevenshteinDistance - the number of changes needed to change one String into another
The StringUtils class defines certain words related to String handling.
null - null
empty - a zero-length string ("")
space - the space character (' ', char 32)
whitespace - the characters defined by Character.isWhitespace(char)
trim - the characters <= 32 as in String.trim()
辅助字符串处理类:org.apache.commons.lang3.StringUtils的更多相关文章
- spring异常记录-----java.lang.NoClassDefFoundError: org/apache/commons/lang3/StringUtils
今天在练习怎样SSH中进行单元測试的时候出现下列异常: SEVERE: Exception starting filter Struts2 java.lang.NoClassDefFoundError ...
- Caused by: java.lang.ClassNotFoundException: org.apache.commons.lang3.StringUtils
1.错误叙述性说明 2014-7-10 23:12:23 org.apache.catalina.core.StandardContext filterStart 严重: Exception star ...
- NoClassDefFoundError: org/apache/commons/lang3/StringUtils
出错信息: 2014-2-5 21:38:05 org.apache.catalina.core.StandardContext filterStart严重: Exception starting f ...
- Hadoop java.lang.ClassNotFoundException: org.apache.commons.lang3.StringUtils
.jar 学习好友推荐案例的时候,提交运行时报错找不到StringUtils java.lang.ClassNotFoundException: org.apache.commons.lang3.St ...
- struts2中的错误--java.lang.NoClassDefFoundError: org/apache/commons/lang3/StringUtils
2013-4-7 10:13:56 org.apache.catalina.startup.HostConfig checkResources 信息: Reloading context [/chap ...
- ERROR----java.lang.NoClassDefFoundError: org/apache/commons/lang3/StringUtils
2013-4-28 13:17:57 org.apache.catalina.core.StandardContext filterStart 严重: Exception starting filte ...
- org.apache.commons.lang3.StringUtils中的StringUtils常用方法
https://my.oschina.net/funmo/blog/615202?p=1 public static void TestStr(){ //null 和 ""操作~~ ...
- org.apache.commons.lang3.StringUtils类中isBlank和isEmpty方法的区别
相信很多java程序员在写代码的时候遇到判断某字符串是否为空的时候会用到StringUtils类中isBlank和isEmpty方法,这两个方法到底有什么区别呢?我们用一段代码来阐述这个区别吧: @T ...
- 【java】java工具类StringUtils,org.apache.commons.lang3.StringUtils
使用过程中,发现StringUtils工具类功能非常的多. 例如,判断元素是否为数字: StringUtils.isNumeric(string)
随机推荐
- vijos1746 floyd
小D的旅行 旅行是一件颇有趣的事情,但是在旅行前规划好路线也很重要. 现在小D计划要去U国旅行. U国有N个城市,M条道路,每条道路都连接着两个城市,并且经过这条道路需要一定的费用wi. 现在小D想要 ...
- axis2的WebService无法注入Service层类
package com.vrv.paw.axiswebservices; import org.springframework.web.context.ContextLoader; import or ...
- currentSession
public class HibernateUtil { public static final ThreadLocal session =new ThreadLocal(); public ...
- 小程序数组型图片自适应效果的实现(交流QQ群:604788754)
//本例代码如有问题,请加群,下载今日日期文件,测试.(如对本例有疑问,也可加群咨询群主) WXML: <view class="imgbox"> <block ...
- Python 数据类型--集合(set)
一.集合(set) 集合也是一种数据类型,一个类似列表的,无序的,不重复的.它主要有两大作用 1.把一个列表变为集合,就自动去重了,不需要写额外的代码 2.关系测试,测试两组数据之间的交际.差集.并集 ...
- C++设计模式之解释器模式
2013年07月06日 19:43:00 阅读数:8853 概述: 未来机器智能化已然成为趋势,现在手机都能听懂英语和普通话,那我大中华几万种方言的被智能化也许也是趋势,我们的方言虽然和普通话相似,但 ...
- SharePoint 2013的100个新功能之内容管理(三)
一:视频中的人 作为视频内容类型的一部分,一个新的栏"视频中的人"被加入到其中,可以指定视频中的人,作为视频的元数据.当你编辑视频属性时可以查看到该栏.更多信息 二:重建索引 一个 ...
- 解决:People下面选择分享可见联系人,选择多个联系人后通过短信分享,短信中只显示一个联系人
问题描述: [操作步骤]:People下导入导出中选择分享可见联系人,选择多个联系人后通过短信分享 [测试结果]:短信中只能显示一个联系人 [预期结果]:可以显示多个联系人 经过代码分析,从compo ...
- 求a^b
时间: 1000ms / 空间: 131072KiB / Java类名: Main 描述 求a^b 由于结果可能很大,我们现在只需要知道这个值 mod 1012就可以了(为什么是1012?我的生日) ...
- Android的界面设计工具——DroidDraw
软件名称:DroidDraw 软件大小:489KB(Windows版本) 支持系统:Mac OS X/Windows/Linux 下载地址:http://code.google.com/p/droid ...