当前位置: 首页>>代码示例>>Java>>正文


Java IOFileFilter类代码示例

本文整理汇总了Java中org.apache.commons.io.filefilter.IOFileFilter的典型用法代码示例。如果您正苦于以下问题:Java IOFileFilter类的具体用法?Java IOFileFilter怎么用?Java IOFileFilter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


IOFileFilter类属于org.apache.commons.io.filefilter包,在下文中一共展示了IOFileFilter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: deleteOldServerResourcesPacks

import org.apache.commons.io.filefilter.IOFileFilter; //导入依赖的package包/类
/**
 * Keep only the 10 most recent resources packs, delete the others
 */
private void deleteOldServerResourcesPacks()
{
    try
    {
        List<File> list = Lists.newArrayList(FileUtils.listFiles(this.dirServerResourcepacks, TrueFileFilter.TRUE, (IOFileFilter)null));
        Collections.sort(list, LastModifiedFileComparator.LASTMODIFIED_REVERSE);
        int i = 0;

        for (File file1 : list)
        {
            if (i++ >= 10)
            {
                LOGGER.info("Deleting old server resource pack {}", new Object[] {file1.getName()});
                FileUtils.deleteQuietly(file1);
            }
        }
    }
    catch (IllegalArgumentException illegalargumentexception)
    {
        LOGGER.error("Error while deleting old server resource pack : {}", new Object[] {illegalargumentexception.getMessage()});
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:26,代码来源:ResourcePackRepository.java

示例2: func_183028_i

import org.apache.commons.io.filefilter.IOFileFilter; //导入依赖的package包/类
private void func_183028_i()
{
    List<File> list = Lists.newArrayList(FileUtils.listFiles(this.dirServerResourcepacks, TrueFileFilter.TRUE, (IOFileFilter)null));
    Collections.sort(list, LastModifiedFileComparator.LASTMODIFIED_REVERSE);
    int i = 0;

    for (File file1 : list)
    {
        if (i++ >= 10)
        {
            logger.info("Deleting old server resource pack " + file1.getName());
            FileUtils.deleteQuietly(file1);
        }
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:16,代码来源:ResourcePackRepository.java

示例3: getAbiSoFiles

import org.apache.commons.io.filefilter.IOFileFilter; //导入依赖的package包/类
/**
 * Verify the directory of the so file under the abi
 *
 * @param supportAbis
 * @param removeSoFiles
 * @param dirs
 * @return
 */
public static Map<String, Multimap<String, File>> getAbiSoFiles(Set<String> supportAbis, Set<String> removeSoFiles,
                                                                List<File> dirs) {
    Map<String, Multimap<String, File>> result = new HashMap<String, Multimap<String, File>>();
    IOFileFilter filter = new NativeSoFilter(supportAbis, removeSoFiles);
    for (File dir : dirs) {
        Collection<File> files = FileUtils.listFiles(dir, filter, TrueFileFilter.TRUE);
        for (File file : files) {
            File parentFolder = file.getParentFile();
            String parentName = parentFolder.getName();
            String shortName = getSoShortName(file);
            Multimap<String, File> maps = result.get(parentName);
            if (null == maps) {
                maps = HashMultimap.create(10, 3);
            }
            maps.put(shortName, file);
            result.put(parentName, maps);
        }

    }
    return result;
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:30,代码来源:NativeSoUtils.java

示例4: copyLocalNativeLibraries

import org.apache.commons.io.filefilter.IOFileFilter; //导入依赖的package包/类
/**
 * @param localNativeLibrariesDirectory
 * @param destinationDirectory
 * @param supportAbis                   Type of architecture supported
 * @param removeSoFiles
 */
public static void copyLocalNativeLibraries(final File localNativeLibrariesDirectory,
                                            final File destinationDirectory, Set<String> supportAbis,
                                            Set<String> removeSoFiles) {
    sLogger.info("Copying existing native libraries from " + localNativeLibrariesDirectory + " to "
                     + destinationDirectory);
    try {
        IOFileFilter filter = new NativeSoFilter(supportAbis, removeSoFiles);
        // First, determine whether there is a file of the same name, if there is a discrepancy
        Collection<File> files = FileUtils.listFiles(localNativeLibrariesDirectory, filter, TrueFileFilter.TRUE);
        List<String> dumpFiles = new ArrayList<String>();
        for (File file : files) {
            String relativePath = getRelativePath(localNativeLibrariesDirectory, file);
            File destFile = new File(destinationDirectory, relativePath);
            if (destFile.exists()) {
                String orgFileMd5 = MD5Util.getFileMD5(file);
                String destFileMd5 = MD5Util.getFileMD5(destFile);
                if (!orgFileMd5.equals(destFileMd5)) {
                    dumpFiles.add(file.getAbsolutePath() + " to " + destFile.getAbsolutePath());
                }
            }
        }
        if (dumpFiles.size() > 0) {
            throw new RuntimeException("Copy native so error,duplicate file exist!:\n"
                                           + StringUtils.join(dumpFiles, "\n"));
        }
        FileUtils.copyDirectory(localNativeLibrariesDirectory, destinationDirectory, filter);
    } catch (IOException e) {
        throw new RuntimeException("Could not copy native dependency.", e);
    }
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:37,代码来源:NativeSoUtils.java

示例5: updateConfigurationFiles

import org.apache.commons.io.filefilter.IOFileFilter; //导入依赖的package包/类
private void updateConfigurationFiles() throws EngineException {
	try {
		IOFileFilter fileFilter = FileFilterUtils.or(FileFilterUtils.suffixFileFilter("json"),FileFilterUtils.suffixFileFilter("xml"),FileFilterUtils.suffixFileFilter("js"));
		IOFileFilter dirFilter = FileFilterUtils.or(FileFilterUtils.nameFileFilter("config"));
		for (File f: FileUtils.listFiles(ionicWorkDir, fileFilter, dirFilter)) {
			String content = FileUtils.readFileToString(f, "UTF-8");
			content = content.replaceAll("../DisplayObjects","../../DisplayObjects");
			content = content.replaceAll("../Flashupdate","../../Flashupdate");
			writeFile(f, content, "UTF-8");
		}
		Engine.logEngine.debug("(MobileBuilder) Configuration files updated for ionic project '"+ project.getName() +"'");
	}
	catch (Exception e) {
		throw new EngineException("Unable to update configuration files for ionic project '"+ project.getName() +"'",e);
	}
}
 
开发者ID:convertigo,项目名称:convertigo-engine,代码行数:17,代码来源:MobileBuilder.java

示例6: innerListFiles

import org.apache.commons.io.filefilter.IOFileFilter; //导入依赖的package包/类
/**
 * Finds files within a given directory (and optionally its
 * subdirectories). All files found are filtered by an IOFileFilter.
 *
 * @param files the collection of files found.
 * @param directory the directory to search in.
 * @param filter the filter to apply to files and directories.
 * @param includeSubDirectories indicates if will include the subdirectories themselves
 */
private static void innerListFiles(Collection<File> files, File directory,
        IOFileFilter filter, boolean includeSubDirectories) {
    File[] found = directory.listFiles((FileFilter) filter);
    
    if (found != null) {
        for (File file : found) {
            if (file.isDirectory()) {
                if (includeSubDirectories) {
                    files.add(file);
                }
                innerListFiles(files, file, filter, includeSubDirectories);
            } else {
                files.add(file);
            }
        }
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:27,代码来源:FileUtils.java

示例7: check1

import org.apache.commons.io.filefilter.IOFileFilter; //导入依赖的package包/类
/**
 * 只监控文件发送变化,如果是子目录的文件改变,则目录会变,由于没有过滤目录发生变化,则目录下的文件改变不会监控到
 * @param dir
 * @throws Exception 
 */
public void check1(String dir) throws Exception
{
	File directory = new File(dir);
    // 轮询间隔 5 秒
    long interval = TimeUnit.SECONDS.toMillis(5);
    // 创建一个文件观察器用于处理文件的格式
    IOFileFilter filter=FileFilterUtils.or(FileFilterUtils.suffixFileFilter(".class"),
    		FileFilterUtils.suffixFileFilter(".jar"));
    FileAlterationObserver observer = new FileAlterationObserver(directory,filter);
    //设置文件变化监听器
    observer.addListener(new MyFileListener());
    FileAlterationMonitor monitor = new FileAlterationMonitor(interval);
    monitor.addObserver(observer);//文件观察
    monitor.start();
}
 
开发者ID:juebanlin,项目名称:util4j,代码行数:21,代码来源:FileMonitor.java

示例8: check2

import org.apache.commons.io.filefilter.IOFileFilter; //导入依赖的package包/类
public void check2(String dir) throws Exception
	{
		File directory = new File(dir);
	    // 轮询间隔 5 秒
	    long interval = TimeUnit.SECONDS.toMillis(5);
	    //后缀过滤器
	    IOFileFilter filefilter=FileFilterUtils.or(FileFilterUtils.suffixFileFilter(".class"),
	    		FileFilterUtils.suffixFileFilter(".jar"));
	    //子目录的后缀
	    IOFileFilter subFilefilter=FileFilterUtils.or(FileFilterUtils.directoryFileFilter(),filefilter);
	    //根目录和子目录变化
	    IOFileFilter filter = FileFilterUtils.or(filefilter,subFilefilter);
	    FileAlterationObserver observer = new FileAlterationObserver(directory,filter);
	    //设置文件变化监听器
	    observer.addListener(new MyFileListener());
	    FileAlterationMonitor monitor = new FileAlterationMonitor(interval);
	    monitor.addObserver(observer);//文件观察
	    monitor.start();
//	    monitor.addObserver(observer);//文件观察,如果在start后面加,则会触发所有文件创建
	}
 
开发者ID:juebanlin,项目名称:util4j,代码行数:21,代码来源:FileMonitor.java

示例9: definitionsFilter

import org.apache.commons.io.filefilter.IOFileFilter; //导入依赖的package包/类
private static IOFileFilter definitionsFilter()
{
    return new IOFileFilter()
    {
        @Override
        public boolean accept(File file)
        {
            return file.isFile();
        }

        @Override
        public boolean accept(File dir, String name)
        {
            return name.endsWith(".json");
        }
    };
}
 
开发者ID:dags-,项目名称:CreativeBlock,代码行数:18,代码来源:FolderBlockPack.java

示例10: textureFilter

import org.apache.commons.io.filefilter.IOFileFilter; //导入依赖的package包/类
private static IOFileFilter textureFilter()
{
    return new IOFileFilter()
    {
        @Override
        public boolean accept(File file)
        {
            return file.isFile();
        }

        @Override
        public boolean accept(File dir, String name)
        {
            return name.endsWith(".png");
        }
    };
}
 
开发者ID:dags-,项目名称:CreativeBlock,代码行数:18,代码来源:FolderBlockPack.java

示例11: getFilesFilter

import org.apache.commons.io.filefilter.IOFileFilter; //导入依赖的package包/类
/**
 * Get a IOFileFilter instance which filter files containing filter value.
 *
 * @param filter
 * @return
 */
public IOFileFilter getFilesFilter(final String filter) {
    IOFileFilter fileFilter = new IOFileFilter() {

        @Override
        public boolean accept(File dir, String name) {
            return dir.getName().contains(name);
        }

        @Override
        public boolean accept(File file) {
            return file.getName().contains(filter);
        }
    };

    return fileFilter;
}
 
开发者ID:nacuteodor,项目名称:SearchInJenkinsLogs,代码行数:23,代码来源:FileHelper.java

示例12: listFiles

import org.apache.commons.io.filefilter.IOFileFilter; //导入依赖的package包/类
/**
 * 找到满足条件的文件,把结果保存到函数的参数中。files 不能在本函数中初始化,因为用到了递归,如果初始化的话,会
 */
private Collection<File> listFiles(File directory, IOFileFilter filter, boolean includeSubDirectories) {

    File[] found = directory.listFiles((FileFilter) filter);

    if (found != null) {
        for (File file : found) {
            if (file.isDirectory()) {
                if (includeSubDirectories) {
                    files.add(file);
                }
                listFiles(file, filter, includeSubDirectories);
            } else {
                files.add(file);
            }
        }
    }
    return files;
}
 
开发者ID:h819,项目名称:spring-boot,代码行数:22,代码来源:RecursiveExample.java

示例13: innerListFiles

import org.apache.commons.io.filefilter.IOFileFilter; //导入依赖的package包/类
/**
 * Finds files within a given directory (and optionally its
 * subdirectories). All files found are filtered by an IOFileFilter.
 *
 * @param files                 the collection of files found.
 * @param directory             the directory to search in.
 * @param filter                the filter to apply to files and directories.
 * @param includeSubDirectories indicates if will include the subdirectories themselves
 */
private static void innerListFiles(final Collection<File> files, final File directory,
                                   final IOFileFilter filter, final boolean includeSubDirectories) {
    final File[] found = directory.listFiles((FileFilter) filter);

    if (found != null) {
        for (final File file : found) {
            if (file.isDirectory()) {
                if (includeSubDirectories) {
                    files.add(file);
                }
                innerListFiles(files, file, filter, includeSubDirectories);
            } else {
                files.add(file);
            }
        }
    }
}
 
开发者ID:PuppyRush,项目名称:WidgetStore,代码行数:27,代码来源:FileUtils.java

示例14: scan

import org.apache.commons.io.filefilter.IOFileFilter; //导入依赖的package包/类
/**
 * Scan all {@link File} {@link Set} that are accepted by {@link IOFileFilter} under root directory
 *
 * @param rootDirectory
 *         Root directory
 * @param recursive
 *         is recursive on sub directories
 * @param ioFileFilter
 *         {@link IOFileFilter}
 * @return Read-only {@link Set} , and the order be dependent on {@link File#listFiles()} implementation
 * @see IOFileFilter
 * @since 1.0.0
 */
@Nonnull
public Set<File> scan(File rootDirectory, boolean recursive, IOFileFilter ioFileFilter) {

    final Set<File> filesSet = Sets.newLinkedHashSet();

    if (ioFileFilter.accept(rootDirectory)) {
        filesSet.add(rootDirectory);
    }

    File[] subFiles = rootDirectory.listFiles();

    if (subFiles != null) {
        for (File subFile : subFiles) {
            if (ioFileFilter.accept(subFile)) {
                filesSet.add(subFile);
            }
            if (recursive && subFile.isDirectory()) {
                filesSet.addAll(this.scan(subFile, recursive, ioFileFilter));
            }
        }
    }
    return Collections.unmodifiableSet(filesSet);
}
 
开发者ID:mercyblitz,项目名称:confucius-commons,代码行数:37,代码来源:SimpleFileScanner.java

示例15: findGitRepos

import org.apache.commons.io.filefilter.IOFileFilter; //导入依赖的package包/类
public static List<String> findGitRepos(String dirPath) {
	File dir = new File(dirPath);
	IOFileFilter gitDirFilter = (IOFileFilter) FileFilterUtils.suffixFileFilter(".git");
	IOFileFilter notFile = FileFilterUtils.notFileFilter(TrueFileFilter.INSTANCE);
	IOFileFilter compositeFilter = FileFilterUtils.and(notFile, gitDirFilter);
	
	List<File> files = (List<File>) FileUtils.listFilesAndDirs(dir,compositeFilter,DirectoryFileFilter.INSTANCE);
	List<String> results = new ArrayList<String>();
	for(File f: files) {
		try {
			if(!f.getCanonicalPath().endsWith("/.git"))
				continue;
			
			String gitStripped = f.getCanonicalPath().replace("/.git", "");
			System.out.println(gitStripped);
			results.add(gitStripped);
			
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	return results;
}
 
开发者ID:wsdookadr,项目名称:mdetect,代码行数:24,代码来源:FileScanUtils.java


注:本文中的org.apache.commons.io.filefilter.IOFileFilter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。