Search code examples
javastringbuffer

String builder append method in java queryStr.append(\\%AMPAMP\\$);


queryStr.append("\\\\%AMPAMP\\\\$"); 

after executing this line the querStr removes

one \ from the string and the final result will be:

"\%AMPAMP\$"

I want it to be:

\\\\%AMPAMP\\\\$

Solution

  • You have to escape the slash:

    queryStr.append("\\\\%AMPAMP\\\\$");