You need to write it like this:
s = s.replaceAll("false", "f"); s = s.replaceAll("true", "t");
Strings are immutable, so once you declare them, they cannot be changed. Call s.replaceAll("false", "f"); creates a new string object with "f" instead of "false" . Since you did not assign this new object to a variable, the new line was basically lost, and your left with the original line.
source share