Java Code Examples for org.apache.commons.io.filefilter.FileFilterUtils#suffixFileFilter()

The following examples show how to use org.apache.commons.io.filefilter.FileFilterUtils#suffixFileFilter() . 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: FilesetSplit.java    From api-mining with GNU General Public License v3.0 6 votes vote down vote up
/**
 * @param args
 */
public static void main(final String[] args) {
	if (args.length < 7) {
		System.err
				.println("Usage fromDirectory toDirectory fileSuffix <<segmentName_i> <weight_i> ...>");
		System.exit(-1);
	}

	final File fromDirectory = new File(args[0]);
	final File toDirectory = new File(args[1]);

	final IOFileFilter fileFilter = FileFilterUtils
			.suffixFileFilter(args[2]);

	final Map<String, Double> segments = Maps.newHashMap();

	for (int i = 3; i < args.length; i += 2) {
		segments.put(args[i], Double.valueOf(args[i + 1]));
	}

	LOGGER.info("Splitting files in segments " + segments);
	splitFiles(fromDirectory, toDirectory, segments, fileFilter,
			UNIFORM_FILE_WEIGHT);
}
 
Example 2
Source File: FilesetSplit.java    From tassal with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * @param args
 */
public static void main(final String[] args) {
	if (args.length < 7) {
		System.err
				.println("Usage fromDirectory toDirectory fileSuffix <<segmentName_i> <weight_i> ...>");
		System.exit(-1);
	}

	final File fromDirectory = new File(args[0]);
	final File toDirectory = new File(args[1]);

	final IOFileFilter fileFilter = FileFilterUtils
			.suffixFileFilter(args[2]);

	final Map<String, Double> segments = Maps.newHashMap();

	for (int i = 3; i < args.length; i += 2) {
		segments.put(args[i], Double.valueOf(args[i + 1]));
	}

	LOGGER.info("Splitting files in segments " + segments);
	splitFiles(fromDirectory, toDirectory, segments, fileFilter,
			UNIFORM_FILE_WEIGHT);
}
 
Example 3
Source File: ImportWorker.java    From magarena with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Copies H2 game stats database file BUT ONLY if the stats folder
 * has been not yet been created (ie. post-install, not if you re-run
 * the import process via the "Reset & restart" option).
 */
private void importGameStats() throws IOException {
    setProgressNote(MText.get(_S14));
    String directoryName = "stats";
    Path sourcePath = importDataPath.resolve(directoryName);
    Path targetPath = MagicFileSystem.getDataPath().resolve(directoryName);
    if (sourcePath.toFile().exists() && MagicFileSystem.isMissingOrEmpty(targetPath)) {
        IOFileFilter dbSuffixFilter = FileFilterUtils.suffixFileFilter(".db");
        FileUtils.copyDirectory(sourcePath.toFile(), targetPath.toFile(), dbSuffixFilter);
    }
    setProgressNote(OK_STRING);
}
 
Example 4
Source File: ImportWorker.java    From magarena with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Merges top level "decks" folder only.
 * Does not import sub-folders (prebuilt, firemind, etc).
 * If file already exists then imported version takes precedence.
 */
private void importCustomDecks() throws IOException {
    setProgressNote(MText.get(_S7));
    final String directoryName = "decks";
    final Path sourcePath = importDataPath.resolve(directoryName);
    if (sourcePath.toFile().exists()) {
        final Path targetPath = MagicFileSystem.getDataPath().resolve(directoryName);
        final IOFileFilter deckSuffixFilter = FileFilterUtils.suffixFileFilter(DeckUtils.DECK_EXTENSION);
        FileUtils.copyDirectory(sourcePath.toFile(), targetPath.toFile(), deckSuffixFilter);
    }
    setProgressNote(OK_STRING);
}
 
Example 5
Source File: LicenseHeaderUpdate.java    From kfs with GNU Affero General Public License v3.0 5 votes vote down vote up
public static void handleSQLStyleComments( String baseDir ) throws Exception {
    IOFileFilter sourceFileFilter = FileFilterUtils.suffixFileFilter("sql");
    sourceFileFilter = FileFilterUtils.makeSVNAware(sourceFileFilter);
    sourceFileFilter = FileFilterUtils.makeFileOnly(sourceFileFilter);

    LicensableFileDirectoryWalker dw = new LicensableFileDirectoryWalker(sourceFileFilter, "--", "-- ", LINE_SEPARATOR);
    Collection<String> results = dw.run( baseDir );
    System.out.println( results );
}