How to Trim a String in Java?

String class provides a method to trim() which returns a copy of the string with leading and trailing white space removed, or the string if it has no leading or trailing white space.
http://www.wikihow.com/Trim-a-String-in-Java