辅助字符串处理类: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)
随机推荐
- hdu-4023-博弈(模拟)
Game Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65768/65768 K (Java/Others)Total Submis ...
- 10046 event 知多少
10046 event 知多少 2017年5月10日 10:08 1.在当前session级打开trace 适用于SQL语句可以在新的session创建后再运行. 在session级收集10046 t ...
- turbine源码分析
turbine源码分析 1.turbine架构设计 一切从InstanceDiscovery模块开始,该模块提供所有的主机信息.它会定期的发送更新,ConnectionManager负责创建连接到主机 ...
- 上传xslx文件设置accept的MIME 类型
.dotx:application/vnd.openxmlformats-officedocument.wordprocessingml.template.docx:application/vnd.o ...
- 如何使用Java Enum
简单的用法:JavaEnum简单的用法一般用于代表一组常用常量,可用来代表一类相同类型的常量值.如: 性别: public enum SexEnum { male, female; } 颜色: pub ...
- Idea破解办法+idea免费生成注册码+jsp属性选择器+注解什么的都报错
Idea破解办法: http://blog.csdn.net/bitcarmanlee/article/details/54951589 idea免费生成注册码: http://idea.iteblo ...
- Dos命令的介绍
Dos命令的介绍目录 1.什么是Dos 2.Dos的简介 3.Dos命令有哪些 4.Dos命令下常见的错误信息 5.Config.sys文件的命令和配置 6.Dos自带的的批处理命令 1.什么是Dos ...
- CF 459A && 459B && 459C && 459D && 459E
http://codeforces.com/contest/459 A题 Pashmak and Garden 化简化简水题,都告诉平行坐标轴了,数据还出了对角线,后面两个点坐标给的范围也不错 #in ...
- 比较强大 优秀的开源框架 :Android图片加载与缓存:Android Glide 的用法
使用Android Glide,需要先下载Android Glide的库,Android Glide在github上的项目主页: https://github.com/bumptech/glide . ...
- FE英文缩写
PM:product manager,产品经理,又称品牌经理,brand managerRD:research and development enginner,研发工程师FE:front-end d ...