zoukankan      html  css  js  c++  java
  • 辅助字符串处理类:org.apache.commons.lang3.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()
    
  • 相关阅读:
    迭代模式
    HackSeven Canvas上的动画
    模板模式
    适配器模式
    豆瓣推荐纪录片
    二手手机十分管用的检查方法
    传参的四种方法
    守夜人誓言+考研誓言
    网络小说分享
    阿里巴巴Java开发手册(详尽版) pdf
  • 原文地址:https://www.cnblogs.com/cag2050/p/8205513.html
Copyright © 2011-2022 走看看