How do you remove the \n, \t and spaces between strings in java?
str.replaceAll("\\s+", "");
\s A whitespace character: [ \t\n\x0B\f\r]
java.util.regex.Pattern
has all the predefined classes.
Use String.replaceAll with a regular expression to remove all whitespace:
s = s.replaceAll("\\s+", "");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With