java list在遍历过程中动态删除元素
if(!ValueWidget.isNullOrEmpty(videoPath)){
if(!videoPath.startsWith("http://")){
String absulotePath=videoPath.replaceAll("^\\.", absulotePrefix);
String videoSize=FileUtils.formatFileSize2(absulotePath,1,false);
tVVideo.setBroadcastSize(videoSize);
File file=new File(absulotePath);
if(!file.exists()){
list.remove(tVVideo);
size=size-1;
i=i-1;
continue;
}
}
}else{
list.remove(tVVideo);
size=size-1;
i=i-1;
continue;
}
要领:
三步骤:
(1)移除元素;
(2)遍历总次数减一
(3)迭代变量减一;