How to replace ' with empty string in Java -


how can replace single quote ' empty string in java. tried following doesn't seem working.

string data="sid's den"; data.replace("'", ""); data.replaceall("'", ""); 

thanks in advance. appreciated.(output should be: sids den)

thanks guys responses. guess should have been more clear question. getting special characters table , value have replace same table. here snippet of code:

query = "select spl_char, replace_with entcon_splchars"; ptsmt = dbconnector.sqlconnection.preparestatement(query); rs = ptsmt.executequery();  while (rs.next()) {         if(data.contains(rs.getstring("spl_char"))){           data = data.replace(rs.getstring("spl_char"),rs.getstring("replace_with"));             }          } 

so whenevr in data have special character ' facing nullpointer exception. please suggest how go ahead this?

strings immutable you'll receive new instance. try

 data = data.replace("'", ""); 

your edit

check return values of getstring() - npe because database table contains null values in 1 of columns spl_char or replace_with.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -