How to remove " " from java string

Viewed 80357

I have a java string with " " from a text file the program accesses with a Buffered Reader object. I have tried string.replaceAll(" ","") and it doesn't seem to work.

Any ideas?

cleaned = cleaned.replace(" "," ");
10 Answers

We can have a regular expression check and replace HTML nbsp;

input.replaceAll("[\\s\\u00A0]+$", "") + "");

It removes non breaking spaces in the input string.

Related