Tuesday 16 April 2019

Removing whitespace from strings in Java

I have a string like this:



mysz = "name=john age=13 year=2001";



I want to remove the whitespaces in the string. I tried trim() but this removes only whitespaces before and after the whole string. I also tried replaceAll("\\W", "") but then the = also gets removed.



How can I achieve a string with:



mysz2 = "name=johnage=13year=2001"

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...