dimanche 1 mars 2015

Java - String replace first and last character upon condition, which method is faster?

I have a list of thousands of strings that may come in the form:



word



or



"more than one word"



I want to remove the "" whenever they are present, so that I can save the string to my DB.


I'm wondering which method is faster:



  1. Using line.replace("\"","");

  2. Validating that first character is '"', then making a substring from character 1 to length - 1.


Or even, is there a better way to do this?


Aucun commentaire:

Enregistrer un commentaire