I'm looking for a simple piece of code that will change all the backslashes in a string to forward slashes using java.
I tried this: word.replaceAll("\","/");
but it will not work. Anyone have a quick fix for this?
Thanks
P.S. I also just noticed that pretty much none of my string operations are working. I tried things like toUpperCase() and nothing happened to the string?!?
replaceAll()
is the wrong method to use in this case, because it uses regular expressions to match.
You want the simpler replace()
method that replaces literals. Try this:
word = word.replace("\\","/");
Notes:
"\\"
is how you code a String that is a single backslashmyString = myString.someMethod();