java.util.ConcurrentModificationException problem

前端 未结 2 577
醉酒成梦
醉酒成梦 2021-02-19 01:22

On this code I get an java.util.ConcurrentModificationException the method is in a webservice and first reads the file and checks if the vakNaam is in the file. Then it will be

2条回答
  •  无人及你
    2021-02-19 01:49

    The Java 5 enhanced for loop uses an Iterator underneath. So When you remove from tempFile the fail fast nature kicks in and throws the Concurrent exception. Use an iterator and call its remove method, which will remove from the underlying Collection.

提交回复
热议问题