Google has made guava-libraries available recently. It may have what you are looking for:
CharMatcher.inRange('', ' ').trimFrom(str)
is equivalent to String.trim(), but you can customize what to trim, refer to the JavaDoc.
For instance, it has its own definition of WHITESPACE which differs from the JDK and is defined according to the latest Unicode standard, so what you need can be written as:
CharMatcher.WHITESPACE.trimFrom(str)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…