List of usage examples for org.apache.commons.io.filefilter SizeFileFilter SizeFileFilter
public SizeFileFilter(long size, boolean acceptLarger)
From source file:org.mycontroller.standalone.utils.McServerFileUtils.java
public static List<String> getImageFilesList() throws IOException { String filesLocation = AppProperties.getInstance().getControllerSettings().getWidgetImageFilesLocation(); String locationCanonicalPath = FileUtils.getFile(filesLocation).getCanonicalPath(); if (!locationCanonicalPath.endsWith(File.separator)) { locationCanonicalPath += File.separator; }//from w w w .java 2s .c om if (FileUtils.getFile(filesLocation).exists()) { List<String> files = new ArrayList<String>(); IOFileFilter ioFileFilter = FileFilterUtils.and( new SuffixFileFilter(IMAGE_DISPLAY_SUFFIX_FILTER, IOCase.INSENSITIVE), new SizeFileFilter(IMAGE_DISPLAY_WIDGET_FILE_SIZE_LIMIT, false)); Collection<File> imageFiles = FileUtils.listFiles(FileUtils.getFile(filesLocation), ioFileFilter, TrueFileFilter.INSTANCE); for (File imageFile : imageFiles) { files.add(imageFile.getCanonicalPath().replace(locationCanonicalPath, "")); if (files.size() >= MAX_FILES_LIMIT) { break; } } return files; } else { throw new FileNotFoundException("File location not found: " + locationCanonicalPath); } }