用enumeration是不能修改它里面的内容的,并且一旦循环检索完毕,
enumeration就被释放了,甚至不能重新检索。所以如果要修改,
应该直接修改books

解决方案 »

  1.   

    再给你一段document:
    NOTE: The functionality of this interface is duplicated by the Iterator interface. In addition, Iterator adds an optional remove operation, and has shorter method names. New implementations should consider using Iterator in preference to Enumeration. 
      

  2.   

    Vector books=new Vector();
    books.addElement("id=2828828bf7ae5d6000f7ae5f9da0000b name=Lance Lavandowska description= url=http://brainopolis.dnsalias.com/roller/page/lance/ weight=0 riority=0 folderId=image= feedUrl=null");
    books.addElement("id=2828828bf7ae5d6000f7ae5f9da0001b name=Lance Lavandowska description= url=http://brainopolis.dnsalias.com/roller/page/lance/ weight=0 riority=0 folderId=image= feedUrl=null");
    books.addElement("id=2828828bf7ae5d6000f7ae5f9da0002b name=Lance Lavandowska description= url=http://brainopolis.dnsalias.com/roller/page/lance/ weight=0 riority=0 folderId=image= feedUrl=null");
    books.addElement("id=2828828bf7ae5d6000f7ae5f9da0003b name=Lance Lavandowska description= url=http://brainopolis.dnsalias.com/roller/page/lance/ weight=0 riority=0 folderId=image= feedUrl=null");
    books.addElement("id=2828828bf7ae5d6000f7ae5f9da0004b name=Lance Lavandowska description= url=http://brainopolis.dnsalias.com/roller/page/lance/ weight=0 riority=0 folderId=image= feedUrl=null");
    books.addElement("id=2828828bf7ae5d6000f7ae5f9da0005b name=Lance Lavandowska description= url=http://brainopolis.dnsalias.com/roller/page/lance/ weight=0 riority=0 folderId=image= feedUrl=null");
    //...

    String target="2828828bf7ae5d6000f7ae5f9da0000b";
        Enumeration bookEnum = books.elements();
        String content="";
        int pos=0;
        Object obj;
        String id="";
        while(bookEnum.hasMoreElements()){
         obj=bookEnum.nextElement();
         content=(String)obj;
         id=content.substring(content.indexOf("=")+1,content.indexOf(" "));
         if(id.equals(target)){
         pos=books.indexOf(obj);
         System.out.println (id);
         break;
         }    
        }
        
        books.remove(obj);
        //...修改content以后
        
        books.add(content);