java 报错: java.util.NoSuchElementException

出错的代码:
Iterator<File> iter = FileUtils.iterateFiles(dicFile, regexFilter, null);
			while(iter.hasNext()) {
				prePicInfoMap.put(iter.next().getName(), Constant.DISPCONTENT_LOGO_PATH + iter.next().getName());
			}



出错原因很简单:多用了一次iter.next()!!!

应改为:
Iterator<File> iter = FileUtils.iterateFiles(dicFile, regexFilter, null);
			while(iter.hasNext()) {
				String fileName = iter.next().getName();
				prePicInfoMap.put(fileName, Constant.DISPCONTENT_LOGO_PATH + fileName);
			}

你可能感兴趣的:(java)