Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to check for double quote in a string?

807580Nov 30 2009 — edited Dec 1 2009
Hi All,
I am working on a bug and while analyzing it found that if the String does not have double quotes,then the logic fails.So can someone please tell me is there an efficient way of checking to see if the String contains double quotes at the beginning and at the end? If the double quotes does not exist,I should be able to append it.I would like to know if it is possible to do this without putting the string in a loop.
Here is the algorithm:

String fieldName = abc;
if(check if fieldName contains doublequotes)
do nothing
else
add double quote (String should look like this : "abc")

Edited by: ShubhaPradeep on Nov 30, 2009 4:42 PM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 29 2009
Added on Nov 30 2009
6 comments
5,458 views