Append apostrophe with string or string items
This code would help in appending apostrophe with the string on both ends.
If there are comma separated items in string, each one would be appended with apostrophes.
Use: Appending apostrophe for query IN clause
If there are comma separated items in string, each one would be appended with apostrophes.
Use: Appending apostrophe for query IN clause
public static final String
appendAppsotophe(String str) {
if(str!=null) {
String
returnData = "";
String
array[] = str.split(",");
returnData
= "'" + array[0] + "'";
for (int i = 1; i <
array.length; i++) {
returnData
+= ",'" + array[i].trim()
+ "'";
}
return returnData;
}
else {
return null;
}
}
No comments:
Post a Comment