Java Code Examples for org.apache.commons.io.filefilter.FileFilterUtils#prefixFileFilter()
The following examples show how to use
org.apache.commons.io.filefilter.FileFilterUtils#prefixFileFilter() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SvnWorkspaceProviderImpl.java From proctor with Apache License 2.0 | 6 votes |
@Override public void run() { try { if (!shutdown.get()) { LOGGER.info("Actively cleaning up directories older than " + TimeUnit.MILLISECONDS.toHours(cleanupAgeMillis) + " hours"); final IOFileFilter olderThanFilter = FileFilterUtils.asFileFilter(olderThanFileFilter(cleanupAgeMillis)); final IOFileFilter tempDirFilter = FileFilterUtils.prefixFileFilter(prefix); /* * Delete directories that are: * older than [clean up age millis] * starts with temp-dir-prefix */ final IOFileFilter deleteAfterMillisFilter = FileFilterUtils.makeDirectoryOnly( FileFilterUtils.andFileFilter(olderThanFilter, tempDirFilter) ); deleteUserDirectories(rootDirectory, deleteAfterMillisFilter); } else { LOGGER.info("Currently shutdown, skipping older-than directory cleanup"); } } catch (Exception e) { LOGGER.error("Unhandled Exception during directory cleanup", e); } }
Example 2
Source File: PrintPreviewDialog.java From pcgen with GNU Lesser General Public License v2.1 | 5 votes |
@Override protected Object[] doInBackground() { IOFileFilter pdfFilter = FileFilterUtils.asFileFilter(this); IOFileFilter suffixFilter = FileFilterUtils.notFileFilter(new SuffixFileFilter(".fo")); IOFileFilter sheetFilter = FileFilterUtils.prefixFileFilter(Constants.CHARACTER_TEMPLATE_PREFIX); IOFileFilter fileFilter = FileFilterUtils.and(pdfFilter, suffixFilter, sheetFilter); IOFileFilter dirFilter = TrueFileFilter.INSTANCE; File dir = new File(ConfigurationSettings.getOutputSheetsDir()); Collection<File> files = FileUtils.listFiles(dir, fileFilter, dirFilter); URI osPath = new File(ConfigurationSettings.getOutputSheetsDir()).toURI(); return files.stream().map(v -> osPath.relativize(v.toURI())).toArray(); }
Example 3
Source File: PrintPreviewDialog.java From pcgen with GNU Lesser General Public License v2.1 | 5 votes |
@Override protected Object[] doInBackground() { IOFileFilter pdfFilter = FileFilterUtils.asFileFilter(this); IOFileFilter suffixFilter = FileFilterUtils.notFileFilter(new SuffixFileFilter(".fo")); IOFileFilter sheetFilter = FileFilterUtils.prefixFileFilter(Constants.CHARACTER_TEMPLATE_PREFIX); IOFileFilter fileFilter = FileFilterUtils.and(pdfFilter, suffixFilter, sheetFilter); IOFileFilter dirFilter = TrueFileFilter.INSTANCE; File dir = new File(ConfigurationSettings.getOutputSheetsDir()); Collection<File> files = FileUtils.listFiles(dir, fileFilter, dirFilter); URI osPath = new File(ConfigurationSettings.getOutputSheetsDir()).toURI(); return files.stream().map(v -> osPath.relativize(v.toURI())).toArray(); }
Example 4
Source File: ExportDialog.java From pcgen with GNU Lesser General Public License v2.1 | 4 votes |
private void refreshFiles() { String outputSheetsDir; SheetFilter sheetFilter = (SheetFilter) exportBox.getSelectedItem(); IOFileFilter ioFilter = FileFilterUtils.asFileFilter(sheetFilter); IOFileFilter prefixFilter; String defaultSheet = null; String outputSheetDirectory = SettingsHandler.getGameAsProperty().get().getOutputSheetDirectory(); if (outputSheetDirectory == null) { outputSheetsDir = ConfigurationSettings.getOutputSheetsDir() + "/" + sheetFilter.getPath(); } else { outputSheetsDir = ConfigurationSettings.getOutputSheetsDir() + "/" + outputSheetDirectory + "/" + sheetFilter.getPath(); } if (partyBox.isSelected()) { prefixFilter = FileFilterUtils.prefixFileFilter(Constants.PARTY_TEMPLATE_PREFIX); } else { CharacterFacade character = (CharacterFacade) characterBox.getSelectedItem(); prefixFilter = FileFilterUtils.prefixFileFilter(Constants.CHARACTER_TEMPLATE_PREFIX); defaultSheet = character.getDefaultOutputSheet(sheetFilter == SheetFilter.PDF); if (StringUtils.isEmpty(defaultSheet)) { defaultSheet = outputSheetsDir + "/" + SettingsHandler.getGameAsProperty().get().getOutputSheetDefault(sheetFilter.getTag()); } } IOFileFilter filter = FileFilterUtils.and(prefixFilter, ioFilter); List<File> files = FileFilterUtils.filterList(filter, allTemplates); Collections.sort(files); URI osPath = new File(outputSheetsDir).toURI(); URI[] uriList = new URI[files.size()]; Arrays.setAll(uriList, i -> osPath.relativize(files.get(i).toURI())); fileList.setListData(uriList); if (StringUtils.isNotEmpty(defaultSheet)) { URI defaultPath = new File(defaultSheet).toURI(); fileList.setSelectedValue(osPath.relativize(defaultPath), true); } }
Example 5
Source File: ExportDialog.java From pcgen with GNU Lesser General Public License v2.1 | 4 votes |
private void refreshFiles() { String outputSheetsDir; SheetFilter sheetFilter = (SheetFilter) exportBox.getSelectedItem(); IOFileFilter ioFilter = FileFilterUtils.asFileFilter(sheetFilter); IOFileFilter prefixFilter; String defaultSheet = null; String outputSheetDirectory = SettingsHandler.getGameAsProperty().get().getOutputSheetDirectory(); if (outputSheetDirectory == null) { outputSheetsDir = ConfigurationSettings.getOutputSheetsDir() + "/" + sheetFilter.getPath(); } else { outputSheetsDir = ConfigurationSettings.getOutputSheetsDir() + "/" + outputSheetDirectory + "/" + sheetFilter.getPath(); } if (partyBox.isSelected()) { prefixFilter = FileFilterUtils.prefixFileFilter(Constants.PARTY_TEMPLATE_PREFIX); } else { CharacterFacade character = (CharacterFacade) characterBox.getSelectedItem(); prefixFilter = FileFilterUtils.prefixFileFilter(Constants.CHARACTER_TEMPLATE_PREFIX); defaultSheet = character.getDefaultOutputSheet(sheetFilter == SheetFilter.PDF); if (StringUtils.isEmpty(defaultSheet)) { defaultSheet = outputSheetsDir + "/" + SettingsHandler.getGameAsProperty().get().getOutputSheetDefault(sheetFilter.getTag()); } } IOFileFilter filter = FileFilterUtils.and(prefixFilter, ioFilter); List<File> files = FileFilterUtils.filterList(filter, allTemplates); Collections.sort(files); URI osPath = new File(outputSheetsDir).toURI(); URI[] uriList = new URI[files.size()]; Arrays.setAll(uriList, i -> osPath.relativize(files.get(i).toURI())); fileList.setListData(uriList); if (StringUtils.isNotEmpty(defaultSheet)) { URI defaultPath = new File(defaultSheet).toURI(); fileList.setSelectedValue(osPath.relativize(defaultPath), true); } }