当前位置:网站首页>Stringutils tool class
Stringutils tool class
2022-07-07 23:35:00 【Wen xiansen】
org.apache.commons.lang3.StringUtils Tool class methods :
| Method name | Meaning of method |
|---|---|
| IsEmpty/IsBlank | Check whether the string contains text |
| Trim/Strip | Remove leading and trailing spaces |
| Equals/Compare | Compare whether the two strings are null Safe |
| startsWith | Check whether the string is prefixed with null Safe start |
| endsWith | Check whether the string is suffixed with null Safe ending |
| IndexOf/LastIndexOf/Contains | Include empty security index check |
| IndexOfAny/LastIndexOfAny/IndexOfAnyBut/LastIndexOfAnyBut | Index of any set of strings |
| ContainsOnly/ContainsNone/ContainsAny | Whether the string contains only / nothing / Any of these characters |
| Substring/Left/Right/Mid | String safe extraction |
| SubstringBefore/SubstringAfter/SubstringBetween | String extraction relative to other strings |
| Split/Join | Split a string into an array of substrings , vice versa |
| Remove/Delete | Delete part of the string |
| Replace/Overlay | Search string , Then replace with another string |
| Chomp/Chop | Delete the last part of the string |
| AppendIfMissing | If there is no suffix , Then a suffix is appended to the end of the string |
| PrependIfMissing | If no prefix exists , Prefix the beginning of the string |
| LeftPad/RightPad/Center/Repeat | Fill string |
| UpperCase/LowerCase/SwapCase/Capitalize/Uncapitalize | Change the case of the string |
| CountMatches | Count the number of times one string appears in another string |
| IsAlpha/IsNumeric/IsWhitespace/IsAsciiPrintable | Check the characters in the string |
| DefaultString | Prevent the input string from being empty |
| Rotate | rotate ( Cyclic shift ) character string |
| Reverse/ReverseDelimited | Reverse string |
| Abbreviate | Use an ellipsis or another given String Abbreviate a string |
| Difference | Compare strings and report their differences |
| LevenshteinDistance | Will a String Convert to another String Number of changes required |
isEmpty series
StringUtils.isEmpty()
Is it empty . You can see " " Spaces will bypass this empty judgment , Because it's a space , Not strictly null , It can lead to isEmpty(" ")=false
StringUtils.isEmpty(null) = true
StringUtils.isEmpty("") = true
StringUtils.isEmpty(" ") = false
StringUtils.isEmpty("bob") = false
StringUtils.isEmpty(" bob ") = false
/**
*
* <p>NOTE: This method changed in Lang version 2.0.
* It no longer trims the CharSequence.
* That functionality is available in isBlank().</p>
*
* @param cs the CharSequence to check, may be null
* @return {@code true} if the CharSequence is empty or null
* @since 3.0 Changed signature from isEmpty(String) to isEmpty(CharSequence)
*/
public static boolean isEmpty(final CharSequence cs) {
return cs == null || cs.length() == 0;
}StringUtils.isNotEmpty()
Equivalent to not empty , = !isEmpty().
public static boolean isNotEmpty(final CharSequence cs) {
return !isEmpty(cs);
}StringUtils.isAnyEmpty()
Whether one is empty , Only one is empty , for true.
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
/**
* @param css the CharSequences to check, may be null or empty
* @return {@code true} if any of the CharSequences are empty or null
* @since 3.2
*/
public static boolean isAnyEmpty(final CharSequence... css) {
if (ArrayUtils.isEmpty(css)) {
return true;
}
for (final CharSequence cs : css){
if (isEmpty(cs)) {
return true;
}
}
return false;
}StringUtils.isNoneEmpty()
amount to !isAnyEmpty(css) , All values must be non null to return true
/**
* <p>Checks if none of the CharSequences are empty ("") or null.</p>
*
* <pre>
* 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
* </pre>
*
* @param css the CharSequences to check, may be null or empty
* @return {@code true} if none of the CharSequences are empty or null
* @since 3.2
*/
public static boolean isNoneEmpty(final CharSequence... css) {
isBank series
StringUtils.isBlank()
Whether it is vacuum value ( Space or null value )
StringUtils.isBlank(null) = true
StringUtils.isBlank("") = true
StringUtils.isBlank(" ") = true
StringUtils.isBlank("bob") = false
StringUtils.isBlank(" bob ") = false
/**
* <p>Checks if a CharSequence is whitespace, empty ("") or null.</p>
* @param cs the CharSequence to check, may be null
* @return {@code true} if the CharSequence is null, empty or whitespace
* @since 2.0
* @since 3.0 Changed signature from isBlank(String) to isBlank(CharSequence)
*/
public static boolean isBlank(final CharSequence cs) {
int strLen;
if (cs == null || (strLen = cs.length()) == 0) {
return true;
}
for (int i = 0; i < strLen; i++) {
if (Character.isWhitespace(cs.charAt(i)) == false) {
return false;
}
}
return true;
}StringUtils.isNotBlank()
Is it really not empty , Not a space or a null value , amount to !isBlank();
public static boolean isNotBlank(final CharSequence cs) {
return !isBlank(cs);
}StringUtils.isAnyBlank()
Whether any vacuum value is included ( Contains spaces or null values )
StringUtils.isAnyBlank(null) = true
StringUtils.isAnyBlank(null, "foo") = true
StringUtils.isAnyBlank(null, null) = true
StringUtils.isAnyBlank("", "bar") = true
StringUtils.isAnyBlank("bob", "") = true
StringUtils.isAnyBlank(" bob ", null) = true
StringUtils.isAnyBlank(" ", "bar") = true
StringUtils.isAnyBlank("foo", "bar") = false
/**
* <p>Checks if any one of the CharSequences are blank ("") or null and not whitespace only..</p>
* @param css the CharSequences to check, may be null or empty
* @return {@code true} if any of the CharSequences are blank or null or whitespace only
* @since 3.2
*/
public static boolean isAnyBlank(final CharSequence... css) {
if (ArrayUtils.isEmpty(css)) {
return true;
}
for (final CharSequence cs : css){
if (isBlank(cs)) {
return true;
}
}
return false;
}StringUtils.isNoneBlank()
Whether none of them contain null values or spaces
StringUtils.isNoneBlank(null) = false
StringUtils.isNoneBlank(null, "foo") = false
StringUtils.isNoneBlank(null, null) = false
StringUtils.isNoneBlank("", "bar") = false
StringUtils.isNoneBlank("bob", "") = false
StringUtils.isNoneBlank(" bob ", null) = false
StringUtils.isNoneBlank(" ", "bar") = false
StringUtils.isNoneBlank("foo", "bar") = true
/**
* <p>Checks if none of the CharSequences are blank ("") or null and whitespace only..</p>
* @param css the CharSequences to check, may be null or empty
* @return {@code true} if none of the CharSequences are blank or null or whitespace only
* @since 3.2
*/
public static boolean isNoneBlank(final CharSequence... css) {
return !isAnyBlank(css);边栏推荐
- USB (XVI) 2022-04-28
- Count the top 10 films at the box office and save them in another file
- SAP HR奖罚信息导出
- UE4_ Ue5 combined with Logitech handle (F710) use record
- LDO穩壓芯片-內部框圖及選型參數
- Right click the idea file to create new. There is no solution to create new servlet
- Summary of SQL single table query 2020.7.27
- The text editor of markdown class should add colors to fonts (including typora, CSDN, etc.)
- ROS2专题(03):ROS1和ROS2的区别【01】
- 深入理解Mysql锁与事务隔离级别
猜你喜欢
![MATLAB signal processing [Q & A essays · 2]](/img/be/0baa92767c3abbda9b0bff47cb3a75.png)
MATLAB signal processing [Q & A essays · 2]

SAP HR 家庭成员信息

Anxin can internally test offline voice module vb-01 to communicate with esp-c3-12f

2022 Season 6 perfect children's model Shaanxi finals came to a successful conclusion

SAP HR奖罚信息导出

Design and implementation of spark offline development framework

高效的S2B2C电商系统,是这样帮助电子材料企业提升应变能力的

Open source hardware small project: anxinco esp-c3f control ws2812

建筑建材行业SRM供应商云协同管理平台解决方案,实现业务应用可扩展可配置
![给出一个数组,如 [7864, 284, 347, 7732, 8498],现在需要将数组中的数字拼接起来,返回「最大的可能拼出的数字」](/img/21/2e99dd6173ab4925ec22290cd4a357.png)
给出一个数组,如 [7864, 284, 347, 7732, 8498],现在需要将数组中的数字拼接起来,返回「最大的可能拼出的数字」
随机推荐
The efficient s2b2c e-commerce system helps electronic material enterprises improve their adaptability in this way
包装行业智能供应链S2B2B商城解决方案:开辟电商消费新生态
Force deduction solution summary 648 word replacement
How to change the formula picture in the paper directly into the formula in word
B_QuRT_User_Guide(37)
Anxin can internally test offline voice module vb-01 to communicate with esp-c3-12f
城联优品作为新力量初注入,相关上市公司股价应声上涨150%
深入理解Mysql锁与事务隔离级别
Explain
PCI-Express接口的PCB布线规则
LeeCode -- 6. Zigzag transformation
生鲜行业数字化采购管理系统:助力生鲜企业解决采购难题,全程线上化采购执行
[stm32+esp8266 connects to Tencent cloud IOT development platform 3] stm32+esp8266-01s dynamically registers devices on Tencent cloud (at instruction mode) -- with source code
Understand TCP's three handshakes and four waves with love
Right click the idea file to create new. There is no solution to create new servlet
Home appliance industry channel business collaboration system solution: help home appliance enterprises quickly realize the Internet of channels
Unity3d Learning Notes 6 - GPU instantiation (1)
StringUtils工具类
B_ QuRT_ User_ Guide(39)
C simple question one