




已阅读5页,还剩18页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
mons.langClass StringUtilsjava.lang.Omons.lang.StringUtilspublic classStringUtilsextendsObjectOperations onStringthat arenullsafe.字符串是null安全的,不会抛出NullPointerException,都做了相应的处理。 IsEmpty/IsBlank- checks if a String contains text IsEmpty/IsBlank检查字符串是否有内容。 Trim/Strip- removes leading and trailing whitespace Trim/Strip删除字符串开始和结尾的空白符。 Equals- compares two strings null-safe Equals比较两个字符串null安全。 IndexOf/LastIndexOf/Contains- null-safe index-of checks IndexOf/LastIndexOf/Contains null安全的索引检查。 IndexOfAny/LastIndexOfAny/IndexOfAnyBut/LastIndexOfAnyBut- index-of any of a set of Strings IndexOfAny/LastIndexOfAny/IndexOfAnyBut/LastIndexOfAnyBut字符串集合索引检查。 ContainsOnly/ContainsNone- does String contains only/none of these characters ContainsOnly/ContainsNone字符在字符串中出现一次或一次也没有出现。 Substring/Left/Right/Mid- null-safe substring extractions Substring/Left/Right/Mid null安全子串的提取。 SubstringBefore/SubstringAfter/SubstringBetween- substring extraction relative to other strings SubstringBefore/SubstringAfter/SubstringBetween子串提取依赖其它字符串。 Split/Join- splits a String into an array of substrings and vice versa Split/Join字符串拆分为子串的字符串数组,反之亦然。 Remove/Delete- removes part of a String Remove/Delete删除部分字符串。 Replace/Overlay- Searches a String and replaces one String with another Replace/Overlay替换字符串的部分字符。 Chomp/Chop- removes the last part of a String Chomp/Chop删除字符串最后的字符。 LeftPad/RightPad/Center/Repeat- pads a String LeftPad/RightPad/Center/Repeat补字符串。 UpperCase/LowerCase/SwapCase/Capitalize/Uncapitalize- changes the case of a String UpperCase/LowerCase/SwapCase/Capitalize/Uncapitalize改变字符串的大小写。 CountMatches- counts the number of occurrences of one String in another CountMatches计算一个字符或字符串在另外一个字符串出现的次数。 IsAlpha/IsNumeric/IsWhitespace/IsAsciiPrintable- checks the characters in a String IsAlpha/IsNumeric/IsWhitespace/IsAsciiPrintable判断字符是否在字符串中。 DefaultString- protects against a null input String DefaultStringnull安全,null转换为字符串。 Reverse/ReverseDelimited- reverses a String Reverse/ReverseDelimited反转字符串。 Abbreviate- abbreviates a string using ellipsis Abbreviate缩写字符串用省略符。 Difference- compares two Strings and reports on their differences Difference比较两个字符串并且返回不同。 LevensteinDistance- the number of changes needed to change one String into another LevensteinDistance一个字符串改变为另一个字符串需要改变的数量。TheStringUtilsclass defines certain words related to String handling.StringUtils类是对字符串的处理。 null null空 empty - a zero-length string ()长度为0的字符串 space - the space character ( , char 32)间隔符 whitespace - the characters defined byCharacter.isWhitespace(char)空格符 trim - the characters = 32 as inString.trim()去掉字符串两边字符=32Version:$Id: StringUtils.java 492377 2007-01-04 01:20:30Z scolebourne $Field Summary字段摘要staticStringEMPTYThe empty String.空字符串。staticintINDEX_NOT_FOUNDRepresents a failed index search.声明失败索引。Constructor Summary构造方法摘要StringUtils()StringUtilsinstances should NOT be constructed in standard programming.StringUtils所有方法都是静态方法,不能在程序中对其进行构造。Method Summary方法摘要staticStringabbreviate(Stringstr, intmaxWidth)Abbreviates a String using ellipses.取得字符串的缩写,str:处理的字符串,maxWidth:宽度,从第一个字符开始1,maxWidth),类似于substring(),返回一个新的字符串,它是此字符串的一个子字符串。staticStringabbreviate(Stringstr, intoffset, intmaxWidth)Abbreviates a String using ellipses.取得字符串的缩写,str:处理的字符串,maxWidth:宽度,从第offset个字符开始offset,axWidth),类似于substring(),返回一个新的字符串,它是此字符串的一个子字符串。staticStringcapitalise(Stringstr)Deprecated.Use the standardly namedcapitalize(String). Method will be removed in Commons Lang 3.0.过时了.用capitalize(String),在Commons Lang 3.0已经没有此方法了。staticStringcapitaliseAllWords(Stringstr)Deprecated.Use the relocatedWordUtils.capitalize(String). Method will be removed in Commons Lang 3.0.过时了.在Commons Lang 3.0已经没有此方法了。staticStringcapitalize(Stringstr)Capitalizes a String changing the first letter to title case as perCharacter.toTitleCase(char).将str手写字母大写,用于名称、头衔等staticStringcenter(Stringstr, intsize)Centers a String in a larger String of sizesizeusing the space character ( ).产生一个字符串返回,该字符串长度等于size,str位于新串的中心,其他位置补空格。如果str为null,则返回null如果size小于str的长度,则返回str本身staticStringcenter(Stringstr, intsize, charpadChar)Centers a String in a larger String of sizesize.产生一个字符串返回,该字符串长度等于size,str位于新串的中心,其他位置补字符padChar。如果str为null,则返回null如果size小于str的长度,则返回str本身staticStringcenter(Stringstr, intsize,StringpadStr)Centers a String in a larger String of sizesize.产生一个字符串返回,该字符串长度等于size,str位于新串的中心,其他位置补字符串padStr。如果str为null,则返回null如果size小于str的长度,则返回str本身staticStringchomp(Stringstr)Removes one newline from end of a String if its there, otherwise leave it alone.以单个词为单位的反转str=”I am yuanyuan !”;chomp(str)=”! yuanyuan anI”;staticStringchomp(Stringstr,Stringseparator)Removesseparatorfrom the end ofstrif its there, otherwise leave it alone.以单个词为单位的反转,从separator开始str=”I am yuanyuan !”;chomp(str ,”!”)=” yuanyuan anI !”;staticStringchompLast(Stringstr)Deprecated.Usechomp(String)instead. Method will be removed in Commons Lang 3.0.过时了.在Commons Lang 3.0已经没有此方法了staticStringchompLast(Stringstr,Stringsep)Deprecated.Usechomp(String,String)instead. Method will be removed in Commons Lang 3.0.过时了.在Commons Lang 3.0已经没有此方法了staticStringchop(Stringstr)Remove the last character from a String.去掉字符串str的最后一个字符。如果字符串以/r/n结尾,则去掉它们。staticStringchopNewline(Stringstr)Deprecated.Usechomp(String)instead. Method will be removed in Commons Lang 3.0.过时了.在Commons Lang 3.0已经没有此方法了staticStringclean(Stringstr)Deprecated.Use the clearer namedtrimToEmpty(String). Method will be removed in Commons Lang 3.0.过时了.在Commons Lang 3.0已经没有此方法了staticStringconcatenate(Objectarray)Deprecated.Use the better namedjoin(Object)instead. Method will be removed in Commons Lang 3.0.过时了.在Commons Lang 3.0已经没有此方法了staticbooleancontains(Stringstr, charsearchChar)Checks if String contains a search character, handlingnull.当此字符串包含指定的字符searchChar值序列时,返回true;处理null。staticbooleancontains(Stringstr,StringsearchStr)Checks if String contains a search String, handlingnull.当此字符串包含指定的字符串searchStr值序列时,返回true;处理null。staticbooleancontainsIgnoreCase(Stringstr,StringsearchStr)Checks if String contains a search String irrespective of case, handlingnull.当此字符串包含指定的字符串searchStr值序列时,忽略大小写,返回true;处理null。staticbooleancontainsNone(Stringstr, charinvalidChars)Checks that the String does not contain certain characters.判断是否字符串str不包含字符数组invalidChars中的字符,如果含有则返回false。staticbooleancontainsNone(Stringstr,StringinvalidChars)Checks that the String does not contain certain characters.判断是否字符串str不包含字符串invalidChars,如果含有则返回false。staticbooleancontainsOnly(Stringstr, charvalid)Checks if the String contains only certain characters.判断是否字符串str包含字符数组valid中的字符,如果含有则返回true。staticbooleancontainsOnly(Stringstr,StringvalidChars)Checks if the String contains only certain characters.判断是否字符串str包含字符串invalidChars,如果含有则返回true。staticintcountMatches(Stringstr,Stringsub)Counts how many times the substring appears in the larger String.计算字符串sub在字符串str中出现的次数。如果str为null或,则返回0staticStringdefaultIfEmpty(Stringstr,StringdefaultStr)Returns either the passed in String, or if the String is empty ornull, the value ofdefaultStr.如果str不是空或者null,返回str,否则返回defaultStr。staticStringdefaultString(Stringstr)Returns either the passed in String, or if the String isnull, an empty String ().如果str不是空返回str,否则返回。staticStringdefaultString(Stringstr,StringdefaultStr)Returns either the passed in String, or if the String isnull, the value ofdefaultStr.如果str不为空,返回str,否则返回defaultStrstaticStringdeleteSpaces(Stringstr)Deprecated.Use the better localizeddeleteWhitespace(String). Method will be removed in Commons Lang 3.0.过时了.在Commons Lang 3.0已经没有此方法了staticStringdeleteWhitespace(Stringstr)Deletes all whitespaces from a String as defined byCharacter.isWhitespace(char).删除字符串中的所有空白符staticStringdifference(Stringstr1,Stringstr2)Compares two Strings, and returns the portion where they differ.比较两个字符串,返回不同的部分。staticbooleanequals(Stringstr1,Stringstr2)Compares two Strings, returningtrueif they are equal.比较两个字符串是否相等。staticbooleanequalsIgnoreCase(Stringstr1,Stringstr2)Compares two Strings, returningtrueif they are equal ignoring the case.比较两个字符串是否相等,区分大小写。staticStringescape(Stringstr)Deprecated.UseStringEscapeUtils.escapeJava(String)This method will be removed in Commons Lang 3.0过时了.在Commons Lang 3.0已经没有此方法了staticStringgetChomp(Stringstr,Stringsep)Deprecated.UsesubstringAfterLast(String, String)instead (although this doesnt include the separator) Method will be removed in Commons Lang 3.0.过时了.在Commons Lang 3.0已经没有此方法了staticintgetLevenshteinDistance(Strings,Stringt)Find the Levenshtein distance between two Strings.计算两个字符串levenshtein距离,在计算相似度是用到这个方法staticStringgetNestedString(Stringstr,Stringtag)Deprecated.Use the better namedsubstringBetween(String, String). Method will be removed in Commons Lang 3.0.过时了.在Commons Lang 3.0已经没有此方法了staticStringgetNestedString(Stringstr,Stringopen,Stringclose)Deprecated.Use the better namedsubstringBetween(String, String, String). Method will be removed in Commons Lang 3.0.过时了.在Commons Lang 3.0已经没有此方法了staticStringgetPrechomp(Stringstr,Stringsep)Deprecated.UsesubstringBefore(String,String)instead (although this doesnt include the separator). Method will be removed in Commons Lang 3.0.过时了.在Commons Lang 3.0已经没有此方法了staticintindexOf(Stringstr, charsearchChar)Finds the first index within a String, handlingnull.返回字符searchChar在字符串str中第一次出现的位置。如果searchChar没有在str中出现则返回-1,如果str为null或,则也返回-1staticintindexOf(Stringstr, charsearchChar, intstartPos)Finds the first index within a String from a start position, handlingnull.返回字符searchChar从startPos开始在字符串str中第一次出现的位置。如果从startPos开始searchChar没有在str中出现则返回-1,如果str为null或,则也返回-1staticintindexOf(Stringstr,StringsearchStr)Finds the first index within a String, handlingnull.返回字符串searchStr在字符串str中第一次出现的位置。如果str为null或searchStr为null则返回-1,如果searchStr为,且str为不为null,则返回0,如果searchStr不在str中,则返回-1staticintindexOf(Stringstr,StringsearchStr, intstartPos)Finds the first index within a String, handlingnull.返回字符串searchStrr从startPos开始在字符串str中第一次出现的位置。如果从startPos开始searchStrr没有在str中出现则返回-1,如果str为null或,则也返回-1staticintindexOfAny(Stringstr, charsearchChars)Search a String to find the first index of any character in the given set of characters.找出字符数组searchChars中的字符第一次出现在字符串str中的位置。如果字符数组中的字符都不在字符串中,则返回-1如果字符串为null或,则返回-1staticintindexOfAny(Stringstr,StringsearchChars)Search a String to find the first index of any character in the given set of characters.找出字符串searchChars中的字符第一次出现在字符串str中的位置。如果字符串searchChars中的字符都不在字符串str中,则返回-1如果searchChars或str为null或为,则返回-1staticintindexOfAny(Stringstr,StringsearchStrs)Find the first index of any of a set of potential substrings.找出字符数组searchStrs中的字符串第一次出现在字符串str中的位置。如果字符串数组searchStrs中的字符都不在字符串str中,则返回-1如果searchStrs或str为null或为,则返回-1staticintindexOfAnyBut(Stringstr, charsearchChars)Search a String to find the first index of any character not in the given set of characters.找出字符串str中不在字符数组searchChars中的第一个字符的位置。如果字符串中的所有字符都在字符数组中,则返回-1如果字符串为null或,则返回-1staticintindexOfAnyBut(Stringstr,StringsearchChars)Search a String to find the first index of any character not in the given set of characters.找出字符串str中不在字符串searchChars中的第一个字符的位置。如果字符串str中的所有字符都在字符串searchChars中,则返回-1如果字符串str或searchChars为null或,则返回-1staticintindexOfDifference(Stringstr1,Stringstr2)Compares two Strings, and returns the index at which the Strings begin to differ.比较两个字符串,返回第一次不同的位置。staticbooleanisAlpha(Stringstr)Checks if the String contains only unicode letters.判断Str是否由字母组成。staticbooleanisAlphanumeric(Stringstr)Checks if the String contains only unicode letters or digits.判断Str是否由字母或数字组成。staticbooleanisAlphanumericSpace(Stringstr)Checks if the String contains only unicode letters, digits or space ( ).判断Str是否由字母、数字或空格组成。staticbooleanisAlphaSpace(Stringstr)Checks if the String contains only unicode letters and space ( ).判断Str是否由字母和空格组成。staticbooleanisAsciiPrintable(Stringstr)Checks if the string contains only ASCII printable characters.判断str是否由ASCII字符组成。staticbooleanisBlank(Stringstr)Checks if a String is whitespace, empty () or null.判断str是否是空格、空字符串或null。staticbooleanisEmpty(Stringstr)Checks if a String is empty () or null.判断str是否是空字符串或null。staticbooleanisNotBlank(Stringstr)Checks if a String is not empty (), not null and not whitespace only.判断str是否不为空且长度不为0且不由空白符(whitespace)构成,等于!isBlank(String str)staticbooleanisNotEmpty(Stringstr)Checks if a String is not empty () and not null.判断某字符串是否非空,等于!isEmpty(String str)staticbooleanisNumeric(Stringstr)Checks if the String contains only unicode digits.判断字符串str是否有数字组成。staticbooleanisNumericSpace(Stringstr)Checks if the String contains only unicode digits or space ( ).判断字符串str是否有数字或空字符组成。staticbooleanisWhitespace(Stringstr)Checks if the String contains only whitespace.判断字符串str是否是空格staticStringjoin(Collectioncollection, charseparator)Joins the elements of the providedCollectioninto a single String containing the provided elements.把collection中的元素通过分隔符separator连接成一个字符串返回。staticStringjoin(Collectioncollection,Stringseparator)Joins the elements of the providedCollectioninto a single String containing the provided elements.把collection中的元素通过分隔字符串separator连接成一个字符串返回。staticStringjoin(Iteratoriterator, charseparator)Joins the elements of the providedIteratorinto a single String containing the provided elements.把iterator中的元素通过分隔字符separator连接成一个字符串返回。staticStringjoin(Iteratoriterator,Stringseparator)Joins the elements of the providedIteratorinto a single String containing the provided elements.把iterator中的元素通过分隔字符串separator连接成一个字符串返回。staticStringjoin(Objectarray)Joins the elements of the provided array into a single String containing the provided list of elements.把数组array中的元素连接成一个字符串返回staticStringjoin(Objectarray, charseparator)Joins the elements of the provided array into a single String containing the provided list of elements.把数组array中的元素通过分隔符separator连接成一个字符串返回。staticStringjoin(Objectarray, charseparator, intstartIndex, intendIndex)Joins the elements of the provided array into a single String containing the provided list of elements.把数组array中的元素通过分隔符separator连接成一个字符串返回,连接的开始位置为startIndex,结束位置为endIndex。staticStringjoin(Objectarray,Stringseparator)Joins the elements of the provided array into a single String containing the provided list of elements.把数组array中的元素通过分隔字符串separator连接成一个字符串返回。staticStringjoin(Objectarray,Stringseparator, intstartIndex, intendIndex)Joins the elements of the provided array into a single String containing the provided list of elements.把数组array中的元素通过分隔字符串separator连接成一个字符串返回,连接的开始位置为startIndex,结束位置为endIndex。staticintlastIndexOf(Stringstr, charsearchChar)Finds the last index within a String, handlingnull.返回字符searchChar在字符串str中最后一次出现的位置。如果searchChar没有在str中出现则返回-1,如果str为null或,则也返回-1staticintlastIndexOf(Stringstr, charsearchChar, intstartPos)Finds the last index within a String from a start position, handlingnull.返回字符串searchStrr从startPos开始在字符串str中最后一次出现的位置。如果从startPos开始searchStrr没有在str中出现则返回-1,如果str为null或,则也返回-1staticintlastIndexOf(Stringstr,StringsearchStr)Finds the last index within a String, handlingnull.返回字符串searchStr在字符串str中最后一次出现的位置。如果str为null或searchStr为null则返回-1,如果searchStr为,且str为不为null,则返回0,如果searchStr不在str中,则返回-1staticintlastIndexOf(Stringstr,StringsearchStr, intstartPos)Finds the first index within a String, handlingnull.返回字符串searchStrr从startPos开始在字符串str中最后一次出现的位置。如果从startPos开始searchStrr没有在str中出现则返回-1,如果str为null或,则也返回-1staticintlastIndexOfAny(Stringstr,StringsearchStrs)Find the latest index of any of a set of potential substrings.找出字符数组searchStrs中的字符串最后一次出现在字符串str中的位置。如果字符串数组searchStrs中的字符都不在字符串str中,则返回-1如果searchStrs或str为null或为,则返回-1staticStringleft(Stringstr, intlen)Gets the leftmostlencharacters of a String.得到字符串str从左边数len长度的子串。如果str为null或为,则返回它本身如果len小于0,则返回staticStringleftPad(Stringstr, intsize)Left pad a String with spaces ( ).如果字符串长度小于size,则在左边补空格使其长度等于size,然后返回如果字符串长度大于等
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年靶点发现与验证技术在创新药物研发中的生物信息学伦理问题报告
- 门店出售协议合同书模板
- 高效的对赌协议合同模板
- 机械加工厂劳务合同范本
- 签订合同后主体变更协议
- 精装修房子购买合同范本
- 甲方如何写合同协议模板
- 村委与贫困户养殖协议书
- 签了认购协议被动签合同
- 电源安装工程合同协议书
- 苏教版四年级下册数学计算题每日一练带答案(共20天)
- 江苏连云港某公司“12.9”爆炸事故报告
- 人教版三年级上下数学试卷合集-综合素质训练
- 沥青混凝土质量保证体系及措施
- 钢筋机械连接技术规程 JGJ 107-2016
- 《亚马逊运营知识》课件
- 农业机械的智能控制
- 克莱德贝尔格曼吹灰器说明书(Jetblower)
- 2024国际技术转让合同(中英文对照)
- 中华人民共和国能源法
- GB/T 3487-2024乘用车轮辋规格系列
评论
0/150
提交评论