锘??xml version="1.0" encoding="utf-8" standalone="yes"?>欧美日韩久久久久,亚洲丶国产丶欧美一区二区三区,中文字幕欧美国产http://www.aygfsteel.com/cyantide/category/36405.htmlzh-cnMon, 01 Dec 2008 16:23:38 GMTMon, 01 Dec 2008 16:23:38 GMT60org.apache.commons.lang.StringUtil鐨勪嬌鐢?杞笘)http://www.aygfsteel.com/cyantide/archive/2008/07/21/216341.html寰瑧娌欐紶寰瑧娌欐紶Mon, 21 Jul 2008 05:47:00 GMThttp://www.aygfsteel.com/cyantide/archive/2008/07/21/216341.htmlhttp://www.aygfsteel.com/cyantide/comments/216341.htmlhttp://www.aygfsteel.com/cyantide/archive/2008/07/21/216341.html#Feedback0http://www.aygfsteel.com/cyantide/comments/commentRss/216341.htmlhttp://www.aygfsteel.com/cyantide/services/trackbacks/216341.htmlStringUtil鍖呭嚱鏁?


1.絀哄瓧絎︿覆媯鏌?/strong>
浣跨敤鍑芥暟: StringUtils.isBlank(testString)
鍑芥暟浠嬬粛: 褰搕estString涓虹┖,闀垮害涓洪浂鎴栬呬粎鐢辯┖鐧藉瓧絎?whitespace)緇勬垚鏃?榪斿洖True;鍚﹀垯榪斿洖False
渚嬬▼:
    String test = "";
    String test2 = "\n\n\t";
    String test3 = null;
    String test4 = "Test";

    System.out.println( "test blank? " + StringUtils.isBlank( test ) );
    System.out.println( "test2 blank? " + StringUtils.isBlank( test2 ) );
    System.out.println( "test3 blank? " + StringUtils.isBlank( test3 ) );
    System.out.println( "test4 blank? " + StringUtils.isBlank( test4 ) );
杈撳嚭濡備笅:
test blank? true
test2 blank? true
test3 blank? true
test4 blank? False
鍑芥暟StringUtils.isNotBlank(testString)鐨勫姛鑳戒笌StringUtils.isBlank(testString)鐩稿弽.


2.娓呴櫎絀虹櫧瀛楃
浣跨敤鍑芥暟: StringUtils.trimToNull(testString)
鍑芥暟浠嬬粛:娓呴櫎鎺塼estString棣栧熬鐨勭┖鐧藉瓧絎?濡傛灉浠卼estString鍏ㄧ敱絀虹櫧瀛楃
(whitespace)緇勬垚鍒欒繑鍥瀗ull
渚嬬▼:
    String test1 = "\t";
    String test2 = "  A  Test  ";
    String test3 = null;

    System.out.println( "test1 trimToNull: " + StringUtils.trimToNull( test1 ) );
    System.out.println( "test2 trimToNull: " + StringUtils.trimToNull( test2 ) );
    System.out.println( "test3 trimToNull: " + StringUtils.trimToNull( test3 ) );

杈撳嚭濡備笅:
test1 trimToNull: null
test2 trimToNull: A  Test
test3 trimToNull: null

娉ㄦ剰錛氬嚱鏁癝tringUtils.trim(testString)涓?br /> StringUtils.trimToNull(testString)鍔熻兘綾諱技錛屼絾testString鐢辯┖鐧藉瓧絎?br /> (whitespace)緇勬垚鏃惰繑鍥為浂闀垮害瀛楃涓層?/p>


3.鍙栧緱瀛楃涓茬殑緙╁啓
浣跨敤鍑芥暟: StringUtils.abbreviate(testString,width)鍜孲tringUtils.abbreviate(testString,offset錛寃idth)
鍑芥暟浠嬬粛:鍦ㄧ粰瀹氱殑width鍐呭彇寰梩estString鐨勭緝鍐?褰搕estString鐨勯暱搴﹀皬浜巜idth鍒欒繑鍥炲師瀛楃涓?
渚嬬▼:
    String test = "This is a test of the abbreviation.";
    String test2 = "Test";

    System.out.println( StringUtils.abbreviate( test, 15 ) );
    System.out.println( StringUtils.abbreviate( test, 5,15 ) );
    System.out.println( StringUtils.abbreviate( test2, 10 ) );
杈撳嚭濡備笅:
This is a te...
...is a test...
Test

4.鍔堝垎瀛楃涓?/strong>
浣跨敤鍑芥暟: StringUtils.split(testString,splitChars,arrayLength)
鍑芥暟浠嬬粛:splitChars涓彲浠ュ寘鍚竴緋誨垪鐨勫瓧絎︿覆鏉ュ妶鍒唗estString,騫跺彲浠ヨ瀹氬緱
鍒版暟緇勭殑闀垮害.娉ㄦ剰璁懼畾闀垮害arrayLength鍜屽妶鍒嗗瓧絎︿覆闂存湁鎶佃Е鍏崇郴,寤鴻涓鑸儏鍐典笅
涓嶈璁懼畾闀垮害.
渚嬬▼:
    String input = "A b,c.d|e";
    String input2 = "Pharmacy, basketball funky";
   

    String[] array1 = StringUtils.split( input, " ,.|");
    String[] array2 = StringUtils.split( input2, " ,", 2 );


    System.out.println( ArrayUtils.toString( array1 ) );
    System.out.println( ArrayUtils.toString( array2 ) );
杈撳嚭濡備笅:
{A,b,c,d,e}
{Pharmacy,basketball funky}

5.鏌ユ壘宓屽瀛楃涓?/strong>
浣跨敤鍑芥暟:StringUtils.substringBetween(testString,header,tail)
鍑芥暟浠嬬粛錛氬湪testString涓彇寰梙eader鍜宼ail涔嬮棿鐨勫瓧絎︿覆銆備笉瀛樺湪鍒欒繑鍥炵┖
渚嬬▼錛?br />     String htmlContent = "ABC1234ABC4567";
    System.out.println(StringUtils.substringBetween(htmlContent, "1234", "4567"));
    System.out.println(StringUtils.substringBetween(htmlContent, "12345", "4567"));
杈撳嚭濡備笅錛?br />     ABC
    null


6.鍘婚櫎灝鵑儴鎹㈣絎?/strong>
浣跨敤鍑芥暟:StringUtils.chomp(testString)
鍑芥暟浠嬬粛:鍘婚櫎testString灝鵑儴鐨勬崲琛岀
渚嬬▼:
    String input = "Hello\n";
    System.out.println( StringUtils.chomp( input ));
    String input2 = "Another test\r\n";
    System.out.println( StringUtils.chomp( input2 ));
杈撳嚭濡備笅:
    Hello
    Another test


7.閲嶅瀛楃涓?/strong>
浣跨敤鍑芥暟:StringUtils.repeat(repeatString,count)
鍑芥暟浠嬬粛:寰楀埌灝唕epeatString閲嶅count嬈″悗鐨勫瓧絎︿覆
渚嬬▼:
    System.out.println( StringUtils.repeat( "*", 10));
    System.out.println( StringUtils.repeat( "China ", 5));
杈撳嚭濡備笅:
    **********
    China China China China China

鍏朵粬鍑芥暟:StringUtils.center( testString, count,repeatString );
鍑芥暟浠嬬粛:鎶妕estString鎻掑叆灝唕epeatString閲嶅澶氭鍚庣殑瀛楃涓蹭腑闂?寰楀埌瀛楃涓?br /> 鐨勬婚暱涓篶ount
渚嬬▼:
    System.out.println( StringUtils.center( "China", 11,"*"));
杈撳嚭濡備笅:
    ***China***


8.棰犲掑瓧絎︿覆
浣跨敤鍑芥暟:StringUtils.reverse(testString)
鍑芥暟浠嬬粛:寰楀埌testString涓瓧絎﹂鍊掑悗鐨勫瓧絎︿覆
渚嬬▼:
    System.out.println( StringUtils.reverse("ABCDE"));
杈撳嚭濡備笅:
    EDCBA

9.鍒ゆ柇瀛楃涓插唴瀹圭殑綾誨瀷
鍑芥暟浠嬬粛:
StringUtils.isNumeric( testString ) :濡傛灉testString鍏ㄧ敱鏁板瓧緇勬垚榪斿洖True
StringUtils.isAlpha( testString ) :濡傛灉testString鍏ㄧ敱瀛楁瘝緇勬垚榪斿洖True
StringUtils.isAlphanumeric( testString ) :濡傛灉testString鍏ㄧ敱鏁板瓧鎴栨暟瀛楃粍
鎴愯繑鍥濼rue
StringUtils.isAlphaspace( testString )  :濡傛灉testString鍏ㄧ敱瀛楁瘝鎴栫┖鏍肩粍
鎴愯繑鍥濼rue

渚嬬▼:
    String state = "Virginia";
    System.out.println( "Is state number? " + StringUtils.isNumeric(
state ) );
    System.out.println( "Is state alpha? " + StringUtils.isAlpha( state )
);
    System.out.println( "Is state alphanumeric? " +StringUtils.isAlphanumeric( state ) );
    System.out.println( "Is state alphaspace? " + StringUtils.isAlphaSpace( state ) );
杈撳嚭濡備笅:
    Is state number? false
    Is state alpha? true
    Is state alphanumeric? true
    Is state alphaspace? true

10.鍙栧緱鏌愬瓧絎︿覆鍦ㄥ彟涓瀛楃涓蹭腑鍑虹幇鐨勬鏁?br /> 浣跨敤鍑芥暟:StringUtils.countMatches(testString,seqString)
鍑芥暟浠嬬粛:鍙栧緱seqString鍦╰estString涓嚭鐜扮殑嬈℃暟,鏈彂鐜板垯榪斿洖闆?br /> 渚嬬▼:
    System.out.println(StringUtils.countMatches( "Chinese People", "e"
));
杈撳嚭:
    4

11.閮ㄥ垎鎴彇瀛楃涓?/strong>
浣跨敤鍑芥暟:
StringUtils.substringBetween(testString,fromString,toString ):鍙栧緱涓ゅ瓧絎?br /> 涔嬮棿鐨勫瓧絎︿覆
StringUtils.substringAfter( ):鍙栧緱鎸囧畾瀛楃涓插悗鐨勫瓧絎︿覆
StringUtils.substringBefore( )錛氬彇寰楁寚瀹氬瓧絎︿覆涔嬪墠鐨勫瓧絎︿覆
StringUtils.substringBeforeLast( )錛氬彇寰楁渶鍚庝竴涓寚瀹氬瓧絎︿覆涔嬪墠鐨勫瓧絎︿覆
StringUtils.substringAfterLast( )錛氬彇寰楁渶鍚庝竴涓寚瀹氬瓧絎︿覆涔嬪悗鐨勫瓧絎︿覆

鍑芥暟浠嬬粛錛氫笂闈㈠簲璇ラ兘璁叉槑鐧戒簡鍚с?br /> 渚嬬▼錛?br />     String formatted = " 25 * (30,40) [50,60] | 30";
    System.out.print("N0: " + StringUtils.substringBeforeLast( formatted, "*" ) );
    System.out.print(", N1: " + StringUtils.substringBetween( formatted, "(", "," ) );
    System.out.print(", N2: " + StringUtils.substringBetween( formatted, ",", ")" ) );
    System.out.print(", N3: " + StringUtils.substringBetween( formatted, "[", "," ) );
    System.out.print(", N4: " + StringUtils.substringBetween( formatted, ",", "]" ) );
    System.out.print(", N5: " + StringUtils.substringAfterLast( formatted, "|" ) );
杈撳嚭濡備笅錛?br />     N0:  25 , N1: 30, N2: 40, N3: 50, N4: 40) [50,60, N5:  30





涓銆佹暟緇勮漿鎴愬瓧絎︿覆錛?
1銆?灝嗘暟緇勪腑鐨勫瓧絎﹁漿鎹負涓涓瓧絎︿覆
灝嗘暟緇勪腑鐨勫瓧絎﹁漿鎹負涓涓瓧絎︿覆

@param strToConv 瑕佽漿鎹㈢殑瀛楃涓?,榛樿浠ラ楀彿鍒嗛殧
@return 榪斿洖涓涓瓧絎︿覆
String[3] s={"a","b","c"}
StringUtil.convString錛坰)="a,b,c"
2銆?static public String converString(String strToConv)
@param strToConv 瑕佽漿鎹㈢殑瀛楃涓?,
@param conv 鍒嗛殧絎?榛樿浠ラ楀彿鍒嗛殧
@return 鍚屾牱榪斿洖涓涓瓧絎︿覆

String[3] s={"a","b","c"}
StringUtil.convString錛坰,"@")="a@b@c"
static public String converString(String strToConv, String conv)


浜屻佺┖鍊兼嫻嬶細
3銆?

Checks if a String is empty ("") or null.


鍒ゆ柇涓涓瓧絎︿覆鏄惁涓虹┖錛岀┖鏍間綔闈炵┖澶勭悊銆?StringUtils.isEmpty(null) = true StringUtils.isEmpty("") = true StringUtils.isEmpty(" ") = false StringUtils.isEmpty("bob") = false StringUtils.isEmpty(" bob ") = false

NOTE: This method changed in Lang version 2.0.

It no longer trims the String.
That functionality is available in isBlank().


@param str the String to check, may be null
@return true if the String is empty or null
public static boolean isEmpty(String str)


涓夈侀潪絀哄鐞嗭細
4銆?
Checks if a String is not empty ("") and not null.


鍒ゆ柇涓涓瓧絎︿覆鏄惁闈炵┖錛岀┖鏍間綔闈炵┖澶勭悊. StringUtils.isNotEmpty(null) = false StringUtils.isNotEmpty("") = false StringUtils.isNotEmpty(" ") = true StringUtils.isNotEmpty("bob") = true StringUtils.isNotEmpty(" bob ") = true

@param str the String to check, may be null
@return true if the String is not empty and not null
public static boolean isNotEmpty(String str)

5銆?

Checks if a String is not empty (""), not null and not whitespace only.


鍒ゆ柇涓涓瓧絎︿覆鏄惁闈炵┖錛岀┖鏍間綔絀哄鐞? StringUtils.isNotBlank(null) = false StringUtils.isNotBlank("") = false StringUtils.isNotBlank(" ") = false StringUtils.isNotBlank("bob") = true StringUtils.isNotBlank(" bob ") = true

@param str the String to check, may be null
@return true if the String is
not empty and not null and not whitespace
@since 2.0
public static boolean isNotBlank(String str)


鍥涖?絀烘牸澶勭悊
6銆?
Removes control characters (char <= 32) from both

ends of this String, handling null by returning
null.


The String is trimmed using {@link String#trim()}.

Trim removes start and end characters <= 32.
To strip whitespace use {@link //strip(String)}.


To trim your choice of characters, use the

{@link //strip(String, String)} methods.


鏍煎紡鍖栦竴涓瓧絎︿覆涓殑絀烘牸錛屾湁闈炵┖鍒ゆ柇澶勭悊錛?StringUtils.trim(null) = null StringUtils.trim("") = "" StringUtils.trim(" ") = "" StringUtils.trim("abc") = "abc" StringUtils.trim(" abc ") = "abc"

@param str the String to be trimmed, may be null
@return the trimmed string, null if null String input
public static String trim(String str)

7銆?


Removes control characters (char <= 32) from both

ends of this String returning null if the String is
empty ("") after the trim or if it is null.

The String is trimmed using {@link String#trim()}.

Trim removes start and end characters <= 32.
To strip whitespace use {@link /stripToNull(String)}.


鏍煎紡鍖栦竴涓瓧絎︿覆涓殑絀烘牸錛屾湁闈炵┖鍒ゆ柇澶勭悊錛屽鏋滀負絀鴻繑鍥瀗ull錛?StringUtils.trimToNull(null) = null StringUtils.trimToNull("") = null StringUtils.trimToNull(" ") = null StringUtils.trimToNull("abc") = "abc" StringUtils.trimToNull(" abc ") = "abc"

@param str the String to be trimmed, may be null
@return the trimmed String,
null if only chars <= 32, empty or null String input
@since 2.0
public static String trimToNull(String str)

8銆?


Removes control characters (char <= 32) from both

ends of this String returning an empty String ("") if the String
is empty ("") after the trim or if it is null.

The String is trimmed using {@link String#trim()}.

Trim removes start and end characters <= 32.
To strip whitespace use {@link /stripToEmpty(String)}.


鏍煎紡鍖栦竴涓瓧絎︿覆涓殑絀烘牸錛屾湁闈炵┖鍒ゆ柇澶勭悊錛屽鏋滀負絀鴻繑鍥?"錛?StringUtils.trimToEmpty(null) = "" StringUtils.trimToEmpty("") = "" StringUtils.trimToEmpty(" ") = "" StringUtils.trimToEmpty("abc") = "abc" StringUtils.trimToEmpty(" abc ") = "abc"

@param str the String to be trimmed, may be null
@return the trimmed String, or an empty String if null input
@since 2.0
public static String trimToEmpty(String str)


浜斻?瀛楃涓叉瘮杈?
9銆?
Compares two Strings, returning true if they are equal.


nulls are handled without exceptions. Two null

references are considered to be equal. The comparison is case sensitive.


鍒ゆ柇涓や釜瀛楃涓叉槸鍚︾浉絳夛紝鏈夐潪絀哄鐞嗐?StringUtils.equals(null, null) = true StringUtils.equals(null, "abc") = false StringUtils.equals("abc", null) = false StringUtils.equals("abc", "abc") = true StringUtils.equals("abc", "ABC") = false

@param str1 the first String, may be null
@param str2 the second String, may be null
@return true if the Strings are equal, case sensitive, or
both null
@see java.lang.String#equals(Object)
public static boolean equals(String str1, String str2)


10銆?

Compares two Strings, returning true if they are equal ignoring

the case.


nulls are handled without exceptions. Two null

references are considered equal. Comparison is case insensitive.


鍒ゆ柇涓や釜瀛楃涓叉槸鍚︾浉絳夛紝鏈夐潪絀哄鐞嗐傚拷鐣ュぇ灝忓啓 StringUtils.equalsIgnoreCase(null, null) = true StringUtils.equalsIgnoreCase(null, "abc") = false StringUtils.equalsIgnoreCase("abc", null) = false StringUtils.equalsIgnoreCase("abc", "abc") = true StringUtils.equalsIgnoreCase("abc", "ABC") = true

@param str1 the first String, may be null
@param str2 the second String, may be null
@return true if the Strings are equal, case insensitive, or
both null
@see java.lang.String#equalsIgnoreCase(String)
public static boolean equalsIgnoreCase(String str1, String str2)


鍏?IndexOf 澶勭悊
11銆?


Finds the first index within a String, handling null.

This method uses {@link String#indexOf(String)}.


A null String will return -1.


榪斿洖瑕佹煡鎵劇殑瀛楃涓叉墍鍦ㄤ綅緗紝鏈夐潪絀哄鐞?StringUtils.indexOf(null, *) = -1 StringUtils.indexOf(*, null) = -1 StringUtils.indexOf("", "") = 0 StringUtils.indexOf("aabaabaa", "a") = 0 StringUtils.indexOf("aabaabaa", "b") = 2 StringUtils.indexOf("aabaabaa", "ab") = 1 StringUtils.indexOf("aabaabaa", "") = 0

@param str the String to check, may be null
@param searchStr the String to find, may be null
@return the first index of the search String,
-1 if no match or null string input
@since 2.0
public static int indexOf(String str, String searchStr)

12銆?

Finds the first index within a String, handling null.

This method uses {@link String#indexOf(String, int)}.


A null String will return -1.

A negative start position is treated as zero.
An empty ("") search String always matches.
A start position greater than the string length only matches
an empty search String.


榪斿洖瑕佺敱鎸囧畾浣嶇疆寮濮嬫煡鎵劇殑瀛楃涓叉墍鍦ㄤ綅緗紝鏈夐潪絀哄鐞?StringUtils.indexOf(null, *, *) = -1 StringUtils.indexOf(*, null, *) = -1 StringUtils.indexOf("", "", 0) = 0 StringUtils.indexOf("aabaabaa", "a", 0) = 0 StringUtils.indexOf("aabaabaa", "b", 0) = 2 StringUtils.indexOf("aabaabaa", "ab", 0) = 1 StringUtils.indexOf("aabaabaa", "b", 3) = 5 StringUtils.indexOf("aabaabaa", "b", 9) = -1 StringUtils.indexOf("aabaabaa", "b", -1) = 2 StringUtils.indexOf("aabaabaa", "", 2) = 2 StringUtils.indexOf("abc", "", 9) = 3

@param str the String to check, may be null
@param searchStr the String to find, may be null
@param startPos the start position, negative treated as zero
@return the first index of the search String,
-1 if no match or null string input
@since 2.0
public static int indexOf(String str, String searchStr, int startPos)


涓冦?瀛愬瓧絎︿覆澶勭悊錛?
13銆?
Gets a substring from the specified String avoiding exceptions.


A negative start position can be used to start n

characters from the end of the String.


A null String will return null.

An empty ("") String will return "".


榪斿洖鎸囧畾浣嶇疆寮濮嬬殑瀛楃涓蹭腑鐨勬墍鏈夊瓧絎?StringUtils.substring(null, *) = null StringUtils.substring("", *) = "" StringUtils.substring("abc", 0) = "abc" StringUtils.substring("abc", 2) = "c" StringUtils.substring("abc", 4) = "" StringUtils.substring("abc", -2) = "bc" StringUtils.substring("abc", -4) = "abc"

@param str the String to get the substring from, may be null
@param start the position to start from, negative means
count back from the end of the String by this many characters
@return substring from start position, null if null String input
public static String substring(String str, int start)

14銆?

Gets a substring from the specified String avoiding exceptions.


A negative start position can be used to start/end n

characters from the end of the String.


The returned substring starts with the character in the start

position and ends before the end position. All postion counting is
zero-based -- i.e., to start at the beginning of the string use
start = 0. Negative start and end positions can be used to
specify offsets relative to the end of the String.


If start is not strictly to the left of end, ""

is returned.


榪斿洖鐢卞紑濮嬩綅緗埌緇撴潫浣嶇疆涔嬮棿鐨勫瓙瀛楃涓?StringUtils.substring(null, *, *) = null StringUtils.substring("", * , *) = ""; StringUtils.substring("abc", 0, 2) = "ab" StringUtils.substring("abc", 2, 0) = "" StringUtils.substring("abc", 2, 4) = "c" StringUtils.substring("abc", 4, 6) = "" StringUtils.substring("abc", 2, 2) = "" StringUtils.substring("abc", -2, -1) = "b" StringUtils.substring("abc", -4, 2) = "ab"

@param str the String to get the substring from, may be null
@param start the position to start from, negative means
count back from the end of the String by this many characters
@param end the position to end at (exclusive), negative means
count back from the end of the String by this many characters
@return substring from start position to end positon,
null if null String input
public static String substring(String str, int start, int end)


15銆?SubStringAfter/SubStringBefore錛堝墠鍚庡瓙瀛楃涓插鐞嗭細


Gets the substring before the first occurance of a separator.

The separator is not returned.


A null string input will return null.

An empty ("") string input will return the empty string.
A null separator will return the input string.


榪斿洖鎸囧畾瀛楃涓蹭箣鍓嶇殑鎵鏈夊瓧絎?StringUtils.substringBefore(null, *) = null StringUtils.substringBefore("", *) = "" StringUtils.substringBefore("abc", "a") = "" StringUtils.substringBefore("abcba", "b") = "a" StringUtils.substringBefore("abc", "c") = "ab" StringUtils.substringBefore("abc", "d") = "abc" StringUtils.substringBefore("abc", "") = "" StringUtils.substringBefore("abc", null) = "abc"

@param str the String to get a substring from, may be null
@param separator the String to search for, may be null
@return the substring before the first occurance of the separator,
null if null String input
@since 2.0
public static String substringBefore(String str, String separator)

16銆?

Gets the substring after the first occurance of a separator.

The separator is not returned.


A null string input will return null.

An empty ("") string input will return the empty string.
A null separator will return the empty string if the
input string is not null.


榪斿洖鎸囧畾瀛楃涓蹭箣鍚庣殑鎵鏈夊瓧絎?StringUtils.substringAfter(null, *) = null StringUtils.substringAfter("", *) = "" StringUtils.substringAfter(*, null) = "" StringUtils.substringAfter("abc", "a") = "bc" StringUtils.substringAfter("abcba", "b") = "cba" StringUtils.substringAfter("abc", "c") = "" StringUtils.substringAfter("abc", "d") = "" StringUtils.substringAfter("abc", "") = "abc"

@param str the String to get a substring from, may be null
@param separator the String to search for, may be null
@return the substring after the first occurance of the separator,
null if null String input
@since 2.0
public static String substringAfter(String str, String separator)

17銆?

Gets the substring before the last occurance of a separator.

The separator is not returned.


A null string input will return null.

An empty ("") string input will return the empty string.
An empty or null separator will return the input string.


榪斿洖鏈鍚庝竴涓寚瀹氬瓧絎︿覆涔嬪墠鐨勬墍鏈夊瓧絎?StringUtils.substringBeforeLast(null, *) = null StringUtils.substringBeforeLast("", *) = "" StringUtils.substringBeforeLast("abcba", "b") = "abc" StringUtils.substringBeforeLast("abc", "c") = "ab" StringUtils.substringBeforeLast("a", "a") = "" StringUtils.substringBeforeLast("a", "z") = "a" StringUtils.substringBeforeLast("a", null) = "a" StringUtils.substringBeforeLast("a", "") = "a"

@param str the String to get a substring from, may be null
@param separator the String to search for, may be null
@return the substring before the last occurance of the separator,
null if null String input
@since 2.0
public static String substringBeforeLast(String str, String separator)

18銆?

Gets the substring after the last occurance of a separator.

The separator is not returned.


A null string input will return null.

An empty ("") string input will return the empty string.
An empty or null separator will return the empty string if
the input string is not null.


榪斿洖鏈鍚庝竴涓寚瀹氬瓧絎︿覆涔嬪悗鐨勬墍鏈夊瓧絎?StringUtils.substringAfterLast(null, *) = null StringUtils.substringAfterLast("", *) = "" StringUtils.substringAfterLast(*, "") = "" StringUtils.substringAfterLast(*, null) = "" StringUtils.substringAfterLast("abc", "a") = "bc" StringUtils.substringAfterLast("abcba", "b") = "a" StringUtils.substringAfterLast("abc", "c") = "" StringUtils.substringAfterLast("a", "a") = "" StringUtils.substringAfterLast("a", "z") = ""

@param str the String to get a substring from, may be null
@param separator the String to search for, may be null
@return the substring after the last occurance of the separator,
null if null String input
@since 2.0
public static String substringAfterLast(String str, String separator)


鍏?Replacing錛堝瓧絎︿覆鏇挎崲錛?
19銆?
Replaces all occurances of a String within another String.


A null reference passed to this method is a no-op.


浠ユ寚瀹氬瓧絎︿覆鏇挎崲鍘熸潵瀛楃涓茬殑鐨勬寚瀹氬瓧絎︿覆 StringUtils.replace(null, *, *) = null StringUtils.replace("", *, *) = "" StringUtils.replace("aba", null, null) = "aba" StringUtils.replace("aba", null, null) = "aba" StringUtils.replace("aba", "a", null) = "aba" StringUtils.replace("aba", "a", "") = "aba" StringUtils.replace("aba", "a", "z") = "zbz"

@param text text to search and replace in, may be null
@param repl the String to search for, may be null
@param with the String to replace with, may be null
@return the text with any replacements processed,
null if null String input
@see #replace(String text, String repl, String with, int max)
public static String replace(String text, String repl, String with)

20銆?

Replaces a String with another String inside a larger String,

for the first max values of the search String.


A null reference passed to this method is a no-op.


浠ユ寚瀹氬瓧絎︿覆鏈澶ф浛鎹㈠師鏉ュ瓧絎︿覆鐨勭殑鎸囧畾瀛楃涓?StringUtils.replace(null, *, *, *) = null StringUtils.replace("", *, *, *) = "" StringUtils.replace("abaa", null, null, 1) = "abaa" StringUtils.replace("abaa", null, null, 1) = "abaa" StringUtils.replace("abaa", "a", null, 1) = "abaa" StringUtils.replace("abaa", "a", "", 1) = "abaa" StringUtils.replace("abaa", "a", "z", 0) = "abaa" StringUtils.replace("abaa", "a", "z", 1) = "zbaa" StringUtils.replace("abaa", "a", "z", 2) = "zbza" StringUtils.replace("abaa", "a", "z", -1) = "zbzz"

@param text text to search and replace in, may be null
@param repl the String to search for, may be null
@param with the String to replace with, may be null
@param max maximum number of values to replace, or -1 if no maximum
@return the text with any replacements processed,
null if null String input
public static String replace(String text, String repl, String with, int max)


涔濄?Case conversion錛堝ぇ灝忓啓杞崲錛?
21銆?

Converts a String to upper case as per {@link String#toUpperCase()}.


A null input String returns null.


灝嗕竴涓瓧絎︿覆鍙樹負澶у啓 StringUtils.upperCase(null) = null StringUtils.upperCase("") = "" StringUtils.upperCase("aBc") = "ABC"

@param str the String to upper case, may be null
@return the upper cased String, null if null String input
public static String upperCase(String str) 22銆?

Converts a String to lower case as per {@link String#toLowerCase()}.


A null input String returns null.


灝嗕竴涓瓧絎︿覆杞崲涓哄皬鍐?StringUtils.lowerCase(null) = null StringUtils.lowerCase("") = "" StringUtils.lowerCase("aBc") = "abc"

@param str the String to lower case, may be null
@return the lower cased String, null if null String input
public static String lowerCase(String str) 23銆?

Capitalizes a String changing the first letter to title case as

per {@link Character#toTitleCase(char)}. No other letters are changed.


For a word based alorithm, see {@link /WordUtils#capitalize(String)}.

A null input String returns null.


StringUtils.capitalize(null) = null StringUtils.capitalize("") = "" StringUtils.capitalize("cat") = "Cat" StringUtils.capitalize("cAt") = "CAt"

@param str the String to capitalize, may be null
@return the capitalized String, null if null String input
@see /WordUtils#capitalize(String)
@see /uncapitalize(String)
@since 2.0
灝嗗瓧絎︿覆涓殑棣栧瓧姣嶅ぇ鍐?
public static String capitalize(String str)

]]>
主站蜘蛛池模板: 平昌县| 宿州市| 高淳县| 兴化市| 兰西县| 定襄县| 张家港市| 曲靖市| 宁南县| 比如县| 海原县| 中卫市| 重庆市| 加查县| 东明县| 抚顺县| 商洛市| 淄博市| 乌拉特前旗| 南平市| 观塘区| 南丹县| 平定县| 砚山县| 伊春市| 兴安县| 乳源| 青岛市| 东源县| 宣武区| 灌南县| 万山特区| 平顺县| 宝应县| 泰和县| 梁山县| 昌邑市| 榆树市| 乌拉特中旗| 阳城县| 萨迦县|