java List 遍历时删除匹配的对象

  1. 云栖社区>
  2. 博客>
  3. 正文

java List 遍历时删除匹配的对象

黄威的世界 2016-05-11 10:28:33 浏览1080 评论0

摘要: 惯例 Java代码   if(!ValueWidget.isNullOrEmpty(videoPath)){                   if(!videoPath.startsWith("http://")){                       String absulotePath=videoPath.

惯例

Java代码  收藏代码
  1. if(!ValueWidget.isNullOrEmpty(videoPath)){  
  2.                 if(!videoPath.startsWith("http://")){  
  3.                     String absulotePath=videoPath.replaceAll("^\\.", absulotePrefix);  
  4.                     String videoSize=FileUtils.formatFileSize2(absulotePath,1,false);  
  5.                     tVVideo.setBroadcastSize(videoSize);  
  6. //                  File file=new File(absulotePath);  
  7.                     if(!file.exists()){  
  8.                         list.remove(tVVideo);  
  9.                         size=size-1;  
  10.                         i=i-1;  
  11.                         continue;  
  12.                     }  
  13.                 }  
  14.             }else{  
  15.                 list.remove(tVVideo);  
  16.                 size=size-1;  
  17.                 i=i-1;  
  18.                 continue;  
  19.             }  

 

 

Java代码  收藏代码
  1. if(!StringUtil.isNullOrEmpty(orgSubAppDetailInfo)){  
  2.                         int sizeOrgSubAppDetailInfo=orgSubAppDetailInfo.size();  
  3.                         for(int j=0;j<sizeOrgSubAppDetailInfo;j++){  
  4.                             //一个app  
  5.                             OneAppDetailInfo oneAppDetailInfo  =orgSubAppDetailInfo.get(j);  
  6.                             if(!StringUtil.isNullOrEmpty(appId)&& !appId.equals(WorkbenchV2Service.changeAppIdToConfigValue(oneAppDetailInfo.getAppId()))){  
  7.                                 orgSubAppDetailInfo.remove(oneAppDetailInfo);  
  8.                                 sizeOrgSubAppDetailInfo=sizeOrgSubAppDetailInfo-1;  
  9.                                 j=j-1;  
  10.                                 continue;  
  11.                             }  
  12.                             oneAppDetailInfo.deserialization();  
  13.                         }  
  14.                     }  

 

【云栖快讯】一站式开发者服务,海量学习资源免费学  详情请点击

网友评论