android - Java String TRIM function not working -


i receiving string server trailing 1 or 2 lines of spaces below given string.

string str = "abc*******                    ********"; 

consider * spaces after string

i have tried few methods like

str = str.trim();  str = str.replace(string.valueof((char) 160), " ").trim();  str = str.replaceall("\u00a0", ""); 

but none working. why not able remove space?

you should try this:

str = str.replaceall("\n", "").trim(); 

you can observe there new line in string . first replace new line "\n" space("") , trim


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -