Avatar of huzefaq
huzefaq
 asked on

How to get a substring of text while converting to String from Clob datatype

Hi guys

I have a DataBean where i am checking for Clob datatypes. If I find one I change it to a string.
Now what i need is that if I can save only the text which is between the following tags

<Description locale="en_US" type="admin">Get 40% of the highest priced item in the shop cart</Description>

So if I can only get "Get 40% of the highest priced item in the shop cart" as a String

Here is my code to convert Clob to String. I would really appreciate any help regarding this
-------------------------------------------------

for (int i = 0 ; i < resVec.size(); i++)
            {
                  Vector rowVector = (Vector) resVec.get(i);
                  for(int j=0 ; j < rowVector.size(); j++){
                        if(rowVector.get(j) instanceof Clob){
                              Clob c = (Clob)rowVector.get(j);
                              //String strClob = c.getSubString((long) 0, (int) c.length()-1);
                              //rowVector.set(j, strClob);
                              StringBuffer sb = new StringBuffer((int)c.length());
                              Reader in = c.getCharacterStream();
                              int buf = -1;
                              while((buf = in.read()) > -1) {
                                    sb.append((char)buf);
                              }
                              in.close();
                              String s = sb.toString();
                              s = s.replaceAll(",", " ");
                              rowVector.set(j, s);
                        }
                  }
---------------------------------------------------------------------------------------
JavaJava EE

Avatar of undefined
Last Comment
keyurkarnik

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
ForceRs

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
ysnky

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
keyurkarnik

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
huzefaq

ASKER
keyurkarnik:

Thanks for your time. Can you please explain your code. I didn't undertsand how I will get the value between description tags. Becasue in the String there will be many tags


Thanks again
SOLUTION
keyurkarnik

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes