title: How to properly trim whitespaces from a string in Java?
body: <p>The JDK's <a href="http://java.sun.com/javase/6/docs/api/java/lang/String.html#trim()" rel="noreferrer">String.trim()</a> method is pretty naive, and only removes ascii control characters.</p>
  
  <p>Apache Commons' <a href="http://commons.apache.org/lang/api/org/apache/commons/lang/StringUtils.html#strip(java.lang.String)" rel="noreferrer">StringUtils.strip()</a> is slightly better, but uses the JDK's <a href="http://java.sun.com/javase/6/docs/api/java/lang/Character.html#isWhitespace(char)" rel="noreferrer">Character.isWhitespace()</a>, which <a href="https://stackoverflow.com/questions/1060570/why-is-non-breaking-space-not-a-whitespace-character-in-java">doesn't recognize non-breaking space as whitespace</a>.</p>
  
  <p>So what would be the most complete, Unicode-compatible, safe and proper way to trim a string in Java?</p>
  
  <p>And incidentally, is there a better library than <code>commons-lang</code> that I should be using for this sort of stuff?</p>