I have a
string that is passed at runtime. I need to parse it and massage the string to be in aceptable form to the database. If I have an apostrophe, I need to ad another in front of it. For example "King's royal duties" should be sent as "King''s royal duties".
I have something like this..
[code]
treatSpeicalChars(String s){
StringBuffer x = new StringBuffer();
for(int i =0;i<s.length;i++){
char ch = charAt(i);
switch(ch){
case '\'' :
x.append("''");
break;
//similarly for other speical chars..
// do something differnt...
default :
x.append(ch);
}
return x.toString();
But my string is returned as is, without the extra "'" added. I tried parsing with extra '\' s for all chars as well. Ideas?
Thanks,
Vasu