[jdom-interest] java.util.ConcurrentModificationException
Jason Hunter
jhunter at xquery.com
Tue Oct 25 19:48:48 PDT 2005
This FAQ entry talks a bit about that:
http://www.jdom.org/docs/faq.html#a0390
Bottom line is you can't modify a list while you walk it. We had an
email exchange about this recently on the list. You should copy the
elements into another list, change each elt in turn, then add that list
back to the document.
-jh-
THIAIMY NGUYEN wrote:
> Hi, I got this message "java.util.ConcurrentModificationException" when
> I want to do element.setText("coucou"); in a loop for(Iterator
> z=courant.getDescendants();z.hasNext();)
>
> Anyone, can help me??Thanks a lots
> -----------------------------------------------------
>
> static void afficheAll1(Element intro,Element p) {
>
> List listRacine = racine.getChildren();
>
> Iterator i = listRacine.iterator();
>
> String introTxt=intro.getName();
> String courantTxt;
> String pTxt=p.getName();
> String chaine;
> Element courant1;
> String chaine1;
>
> while(i.hasNext()){
> Element courant = (Element)i.next();
> courantTxt=courant.getName();
> if(courantTxt.equals(introTxt)){
>
> for(Iterator z=courant.getDescendants();z.hasNext();){
> Object node=z.next();
>
> if(node instanceof Element){
> courant1=(Element)node;
> String courantNode =courant1.getName();
> if(courantNode.equals(pTxt)){
>
> chaine=courant1.getText();
> chaine=traitementChaine(chaine);
> chaine=traitementChaine1(chaine);
>
> courant1.setText("coucou");
>
> }
>
> }
>
> }
>
> }
> }
> }
>
>
> _______________________________________________
> To control your jdom-interest membership:
> http://www.jdom.org/mailman/options/jdom-interest/youraddr@yourhost.com
>
More information about the jdom-interest
mailing list