I am writing some simple java code that looks in a string to find a value called REPLACEALL
. Once it finds that string I have it replace it with a path name as a value (ex:D:\test\path\something
). However, when I run the code it replace it fine but it removes the single \
. I am not sure why and have set up a debug to see where it is happening. The original string gets passed in fine, its only when the string goes through the replaceAll()
that it causes this issue.
Java:
String path = "D:\test\path\something";
String s1="select * from Webserver WHERE data= REPLCAEME";
String replaceString=s1.replaceAll("REPLACEME"," ' " + path + " ' ");
System.out.println(replaceString);