What is a good alternative of JavaScript ltrim() and rtrim() functions in Java?
Based on the answer of @bezmax I had a look at the Spring StringUtils, but it couldn't justify the overload for me of switching to the Spring framework. Therfore I decided to create a Characters class to easily left / right trim strings for any given character(-class). The class is available on GitHub.
Characters.valueOf('x').trim( ... )
Characters.valueOf('x').leftTrim( ... )
Characters.valueOf('x').rightTrim( ... )
If you would like to trim for whitespaces, there is a predefined character-class available:
Characters.WHITESPACE.trim( ... )
Characters.WHITESPACE.leftTrim( ... )
Characters.WHITESPACE.rightTrim( ... )
The class does feature also other kinds of character operations, such condense, replace or split.