SyntaxFix
Write A Post
Hire A Developer
Questions
The code you want is
str.replaceAll("\\s","");
This will remove all the white spaces.