List of usage examples for org.apache.commons.io.filefilter SuffixFileFilter accept
public boolean accept(File file)
From source file:algorithm.MetsSubmissionInformationPackage.java
@Override protected List<RestoredFile> restore(File outputFile) throws IOException { List<RestoredFile> restoredFiles = new ArrayList<RestoredFile>(); List<String> zipExtension = new ArrayList<String>(); zipExtension.add("zip"); SuffixFileFilter zipFilter = new SuffixFileFilter(zipExtension); List<String> tarExtension = new ArrayList<String>(); tarExtension.add("tar"); SuffixFileFilter tarFilter = new SuffixFileFilter(tarExtension); if (zipFilter.accept(outputFile)) { restoredFiles = new ZipPackaging().restore(outputFile); } else if (tarFilter.accept(outputFile)) { restoredFiles = new TarPackaging().restore(outputFile); }/*from www . j a v a2 s .c o m*/ for (RestoredFile file : restoredFiles) { file.algorithm = this; } return restoredFiles; }
From source file:org.ballerinalang.composer.service.fs.LocalFileSystem.java
/** * {@inheritDoc}/* w w w .java 2s.c o m*/ */ @Override public JsonArray listFilesInPath(String path, List<String> extensions) throws IOException { Path ioPath = Paths.get(path); JsonArray dirs = new JsonArray(); Iterator<Path> iterator = Files.list(ioPath).sorted().iterator(); while (iterator.hasNext()) { Path next = iterator.next(); if ((Files.isDirectory(next) || Files.isRegularFile(next)) && !Files.isHidden(next) && !isWindowsSystemFile(next)) { JsonObject jsnObj = getJsonObjForFile(next, extensions); if (Files.isRegularFile(next)) { Path fileName = next.getFileName(); SuffixFileFilter fileFilter = new SuffixFileFilter(extensions, INSENSITIVE); if (null != fileName && fileFilter.accept(next.toFile())) { jsnObj.addProperty(FILE_FULL_PATH, next.toString()); jsnObj.addProperty(FILE_NAME, FilenameUtils.getBaseName(next.toString())); jsnObj.addProperty(FILE_PATH, FilenameUtils.getFullPath(next.toString())); jsnObj.addProperty(EXTENSION, FilenameUtils.getExtension(next.toString())); dirs.add(jsnObj); } } else { dirs.add(jsnObj); } } } return dirs; }
From source file:org.ballerinalang.composer.service.workspace.local.LocalFSWorkspace.java
/** * {@inheritDoc}// w w w . j a v a 2 s . co m */ @Override public JsonArray listFilesInPath(String path, List<String> extensions) throws IOException { Path ioPath = Paths.get(path); JsonArray dirs = new JsonArray(); Iterator<Path> iterator = Files.list(ioPath).iterator(); while (iterator.hasNext()) { Path next = iterator.next(); if ((Files.isDirectory(next) || Files.isRegularFile(next)) && !Files.isHidden(next) && !isWindowsSystemFile(next)) { JsonObject jsnObj = getJsonObjForFile(next, true); if (Files.isRegularFile(next)) { Path fileName = next.getFileName(); SuffixFileFilter fileFilter = new SuffixFileFilter(extensions, IOCase.INSENSITIVE); if (null != fileName && fileFilter.accept(next.toFile())) { dirs.add(jsnObj); } } else { dirs.add(jsnObj); } } } return dirs; }
From source file:ryerson.daspub.model.Submission.java
/** * Determine if submission is a PDF file. * @return True if submission is a PDF document, false otherwise. *//*ww w . j a v a 2 s. co m*/ public boolean isPDF() { SuffixFileFilter sff = new SuffixFileFilter("pdf"); if (sff.accept(source)) { return true; } return false; }