How do I remove leading and trailing white space from string?
Category: java.lang, viewed: 833 time(s).
package org.kodejava.example.lang; public class TrimStringExample { public static void main(String[] args) { String text = " tattarrattat "; // // The trim() method will result a new string object with a leading and // trailing while space removed. // System.out.println("Result: " + text.trim()); } } |
Can't find what you are looking for? Join our FORUMS and ask some questions!
Related Examples
- How do I read system property as an integer?
- How do I decode string to integer?
- How do I insert a string in the StringBuilder?
- How do I remove substring from StringBuilder?
- How do I reverse a string by word?
- How do I convert varargs to an array?
- How do I remove trailing white space from a string?
- How do I remove leading white space from a string?
- How do I create a method that accept varargs in Java?
- How do I know a class of an object?