While  
is a non breaking space (a space that does not want to be treated as whitespace), you can trim a string while preserving every  
within the string with a simple regex:
string.replaceAll("(^\\h*)|(\\h*$)","")
\h
is a horizontal whitespace character:[ \t\xA0\u1680\u180e\u2000-\u200a\u202f\u205f\u3000]
If you are using a pre JDK8 Version, you need to explicitly use the list of chars instead of \h
.