str = str.replaceAll("\\\\", "");
or
str = str.replace("\\", "");
replaceAll() treats the first argument as a regex, so you have to double escape the backslash. replace() treats it as a literal string, so you only have to escape it once.
str = str.replaceAll("\\\\", "");
or
str = str.replace("\\", "");
replaceAll() treats the first argument as a regex, so you have to double escape the backslash. replace() treats it as a literal string, so you only have to escape it once.