About 102,000 results
Open links in new tab
  1. Difference between String trim() and strip() methods

    Here is a table showing the characters removed by each command: trim (Java 1.0+) & strip (Java 11+). This table illustrates the definition of whitespace as seen in Java 24.

  2. Java String trim has no effect - Stack Overflow

    Jul 28, 2012 · The character is a non-breaking space, and is thus not removed by the trim() method. Iterate through the characters and print the int value of each one, to know which …

  3. Correct way to trim a string in Java - Stack Overflow

    A new String object is created, representing the substring of this string that begins with the character at index k and ends with the character at index m-that is, the result of this.substring …

  4. Strip Leading and Trailing Spaces From Java String

    Jul 11, 2011 · With Java-11 and above, you can make use of the String.strip API to return a string whose value is this string, with all leading and trailing whitespace removed.

  5. string - Trim characters in Java - Stack Overflow

    How can I trim characters in Java? e.g. String j = “\\joe\\jill\\”.Trim(new char[] {“\\”}); j should be "joe\\jill" String j = “jack\\joe\\jill\\”.Trim ...

  6. java - Trim leading or trailing characters from a string ... - Stack ...

    Oct 8, 2021 · How can I trim the leading or trailing characters from a string in java? For example, the slash character "/" - I'm not interested in spaces, and am looking to trim either leading or …

  7. Removing whitespace from strings in Java - Stack Overflow

    Mar 28, 2011 · I have a string like this: mysz = "name=john age=13 year=2001"; I want to remove the whitespaces in the string. I tried trim() but this removes only whitespaces before and after …

  8. Want to make left and right trim on Java String - Stack Overflow

    Apr 14, 2017 · It's impossible, because strings in Java are immutable. If you wish to trim whitespaces from your string and then proceed to work with trimmed version of the string, you …

  9. java - How to remove newlines from beginning and end of a string ...

    Aug 3, 2020 · 373 Use String.trim() method to get rid of whitespaces (spaces, new lines etc.) from the beginning and end of the string.

  10. Java trim() : Cleanest way to check null string before trimming?

    Jun 6, 2022 · I use trim() method in order to trim leading and trailing whitespaces in some of the string field. siteRequest.getName().trim(); However, when string field is null, it throws …