I am getting three types of value from the database when I am fet开发者_如何学Goching value from a field.
All values are with double quotes. Those values are "Fitness Head
, Fiteness " Head
and Fitness Head"
. I have to replace all double quotes with double double quotes using Java. What will be the java code to do that?
Thanks, Somnath
You don't need to replace double quotes anywhere if you are using JDBC to insert/fetch the values - this is all taken care of as long as you use PreparedStatement
s and placeholders.
See this tutorial.
Use String.replace
For example
String doubleQuotes = "\"Fitness head";
doubleQuotes.replace("\"", "\"\"");
Replacing single double quotes with double double quotes:
"abc\"def".replace("\"", "\"\"")
What about this:
String newValue = oldValue.replace("\"", "\"\"");
精彩评论