Stringutils tool class

Source: Internet
Author: User
1 abbreviate Method
Java code
  1. Stringutils. abbreviate ("abcdefghijklmno",-1, 10) = "abcdefg ..."
StringUtils.abbreviate("abcdefghijklmno", -1, 10) = "abcdefg..."

2. Differences between isblank and isempty Java code

  1. Stringutils. isblank ("") = true
  2. Stringutils. isempty ("") = false
StringUtils.isBlank(" ")       = trueStringUtils.isEmpty(" ")       = false

3 join method Java code

  1. Stringutils. Join (["A", "B", "C"], "--") = "A -- B -- C"
  2. Stringutils. Join (list ,",")
StringUtils.join(["a", "b", "c"], "--")  = "a--b--c"StringUtils.join(list, ",")

4 replaceonce method replaces the target string once Java code

  1. Stringutils. replaceonce ("ABA", "A", "") = "ba"
StringUtils.replaceOnce("aba", "a", "")    = "ba"

5 The overlay method overwrites the original string Java code.

  1. Stringutils. overlay ("abcdef", "ZZZZ",-1, 4) = "zzzzzzef"
StringUtils.overlay("abcdef", "zzzz", -1, 4)  = "zzzzef"

6. The chomp method removes the following string Java code.

  1. Stringutils. Chomp ("foobar", "bar") = "foo"
  2. Stringutils. Chomp ("foobar", "Baz") = "foobar"
StringUtils.chomp("foobar", "bar") = "foo"StringUtils.chomp("foobar", "baz") = "foobar"

7. Remove the carriage return letter \ r \ n from the chopnewline method.

8. The padding method is used to complete the Java code.

  1. Stringutils. Padding (3, 'E') = "eee"
StringUtils.padding(3, 'e')  = "eee"

9 center Center Method Java code

  1. Stringutils. Center ("A", 4) = ""
StringUtils.center("a", 4)    = " a  "

10 capitalize method capitalized Java code

  1. Stringutils. capitalize ("cat") = "cat"
StringUtils.capitalize("cat") = "Cat"

11 swapcase method case-insensitive Java code

  1. Stringutils. swapcase ("the dog has a bone") = "the dog has a bone"
StringUtils.swapCase("The dog has a BONE") = "tHE DOG HAS A bone"

12 The isalpha method checks whether the string contains only Unicode letters and Java code.

  1. Stringutils. isalpha ("ABC") = true
  2. Stringutils. isalpha ("ab2c") = false
  3. Stringutils. isalpha ("AB-c") = false
StringUtils.isAlpha("abc")  = trueStringUtils.isAlpha("ab2c") = falseStringUtils.isAlpha("ab-c") = false

13. The isalphaspace method checks whether the string contains only Unicode letters and ''space Java code.

  1. Stringutils. isalphaspace ("ab2c") = false
  2. Stringutils. isalphaspace ("AB C") = true
  3. Stringutils. isalphaspace ("AB-c") = false
StringUtils.isAlphaSpace("ab2c") = falseStringUtils.isAlphaSpace("ab c") = trueStringUtils.isAlphaSpace("ab-c") = false

14. The isalphanumeric method checks whether a string contains only Unicode letters and numbers.
15 The isalphanumericspace method checks whether a string contains only Unicode letters, numbers, and spaces.
16 The isasciiprintable method checks whether the string contains only printable ASCII characters in Java code.

  1. Stringutils. isasciiprintable ("! AB-C ~ ") = True
  2. Stringutils. isasciiprintable ("\ u0020") = true
  3. Stringutils. isasciiprintable ("ceki g \ u00fclc \ u00fc") = false
StringUtils.isAsciiPrintable("!ab-c~") = trueStringUtils.isAsciiPrintable("\u0020") = trueStringUtils.isAsciiPrintable("Ceki G\u00fclc\u00fc") = false

17 The isnumeric method checks whether the string contains only numbers.
18 The iswhitespace method checks whether all strings are empty.

19 The Reverse Method reverses the string Java code

  1. Stringutils. Reverse ("Bat") = "tab"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.