當前位置: 首頁>>代碼示例>>Java>>正文


Java TrueFileFilter類代碼示例

本文整理匯總了Java中org.apache.commons.io.filefilter.TrueFileFilter的典型用法代碼示例。如果您正苦於以下問題:Java TrueFileFilter類的具體用法?Java TrueFileFilter怎麽用?Java TrueFileFilter使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


TrueFileFilter類屬於org.apache.commons.io.filefilter包,在下文中一共展示了TrueFileFilter類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getExecutable

import org.apache.commons.io.filefilter.TrueFileFilter; //導入依賴的package包/類
private String getExecutable() {
    File supposedExecutable = new File(executableDir + executableName);

    if(supposedExecutable.exists()) {
        return supposedExecutable.getAbsolutePath();
    } else {
        Collection<File> theExecutable = FileUtils.listFiles(new File(executableDir), new WildcardFileFilter(executableName), TrueFileFilter.INSTANCE);

        if(theExecutable != null || theExecutable.size() > 1 || theExecutable.isEmpty()) {
            File newestExecutable = theExecutable.stream().reduce(new File(""),
                    (aFile, newestFile) -> {
                        if(aFile.lastModified() > newestFile.lastModified()) {
                            return aFile;
                        }

                        return newestFile;
                    });

            return newestExecutable.getAbsolutePath();
        } else if(theExecutable.size() == 1) {
            return ((File)CollectionUtils.get(theExecutable, 0)).getAbsolutePath();
        } else {
            throw new RuntimeException("Could not determine executable path");
        }
    }
}
 
開發者ID:corydissinger,項目名稱:mtgo-best-bot,代碼行數:27,代碼來源:ProcessManager.java

示例2: generate

import org.apache.commons.io.filefilter.TrueFileFilter; //導入依賴的package包/類
@Override
public void generate(Api api, File outputPath) throws IOException {
    if (outputPath.exists()) {
        Collection<File> files = FileUtils.listFiles(
                outputPath,
                TrueFileFilter.INSTANCE,
                TrueFileFilter.INSTANCE
        );
        for (File file : files) {
            if (file.isFile()) {
                Files.deleteIfExists(file.toPath());
            }
        }
    } else {
        Files.createDirectories(outputPath.toPath());
    }

    TypesGenerator generator = new TypesGenerator();
    generator.generate(api.getTypes(), new File(outputPath, "types") );

}
 
開發者ID:vrapio,項目名稱:rest-modeling-framework,代碼行數:22,代碼來源:MdGenerator.java

示例3: prepareApkFileList

import org.apache.commons.io.filefilter.TrueFileFilter; //導入依賴的package包/類
protected static void prepareApkFileList(File folder, String prefixName, String awbName, ApkFiles apkFiles) {
    if (!folder.exists()) {
        return;
    }
    // Gets information about the main bundle
    Collection<File> files = FileUtils.listFiles(folder, new PureFileFilter(), TrueFileFilter.INSTANCE);
    for (File file : files) {
        if (file.isFile()) {
            String relativePath = prefixName + File.separator + PathUtil.toRelative(folder, file.getAbsolutePath());
            String md5 = MD5Util.getFileMD5(file);
            if (isImageFile(relativePath)) {
                if (null == apkFiles.apkFileList.getAwbs().get(awbName)) {
                    apkFiles.apkFileList.getAwbs().put(awbName, new HashMap<String, String>());
                }
                apkFiles.apkFileList.getAwbs().get(awbName).put(relativePath, md5);
            }
            if (null == apkFiles.finalApkFileList.getAwbs().get(awbName)) {
                apkFiles.finalApkFileList.getAwbs().put(awbName, new HashMap<String, String>());
            }
            apkFiles.finalApkFileList.getAwbs().get(awbName).put(relativePath, md5);
        }
    }

}
 
開發者ID:alibaba,項目名稱:atlas,代碼行數:25,代碼來源:ApkFileListUtils.java

示例4: getResourcesWithExtension

import org.apache.commons.io.filefilter.TrueFileFilter; //導入依賴的package包/類
public ArrayList<String> getResourcesWithExtension(String ext, String containerName) {
	ArrayList<String> ret = new ArrayList<String>();
	if (containerName != null) {
		String[] names = StringUtils.split(containerName, "/");
		IWorkspaceRoot wsRoot = ResourcesPlugin.getWorkspace().getRoot();
		IResource resource = wsRoot.findMember(new Path("/" + names[0]));
		IPath loc = resource.getLocation();
		File prjLoc = new File(loc.toString());
		Collection<File> res = FileUtils.listFiles(prjLoc, FileFilterUtils.suffixFileFilter(ext, IOCase.INSENSITIVE), TrueFileFilter.INSTANCE);
		for (File file : res)
			ret.add(file.getAbsolutePath());
	}
	return ret;
}
 
開發者ID:dstl,項目名稱:Open_Source_ECOA_Toolset_AS5,代碼行數:15,代碼來源:PluginUtil.java

示例5: deleteOldServerResourcesPacks

import org.apache.commons.io.filefilter.TrueFileFilter; //導入依賴的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

示例6: listFiles

import org.apache.commons.io.filefilter.TrueFileFilter; //導入依賴的package包/類
public void listFiles(String rootDir){
	File dir = new File(rootDir);

	List<File> files = (List<File>) FileUtils.listFiles(dir, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE);
	for (File file : files) {
		System.out.println("file: " + file.getAbsolutePath());
	}
}
 
開發者ID:PacktPublishing,項目名稱:Java-Data-Science-Cookbook,代碼行數:9,代碼來源:FileListing.java

示例7: func_183028_i

import org.apache.commons.io.filefilter.TrueFileFilter; //導入依賴的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

示例8: addDirectory

import org.apache.commons.io.filefilter.TrueFileFilter; //導入依賴的package包/類
protected void addDirectory(JarOutputStream jos, File directory, String prefix) throws PatchException {
    if (directory != null && directory.exists()) {
        Collection files = FileUtils.listFiles(directory, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE);
        byte[] buf = new byte[8064];
        Iterator var6 = files.iterator();

        while (true) {
            File file;
            do {
                if (!var6.hasNext()) {
                    return;
                }

                file = (File) var6.next();
            } while (file.isDirectory());

            String path = prefix + File.separator + PathUtils.toRelative(directory, file.getAbsolutePath());
            FileInputStream in = null;

            try {
                in = new FileInputStream(file);
                ZipEntry e = new ZipEntry(path);
                jos.putNextEntry(e);

                int len;
                while ((len = in.read(buf)) > 0) {
                    jos.write(buf, 0, len);
                }

                jos.closeEntry();
                in.close();
            } catch (IOException var12) {
                throw new PatchException(var12.getMessage(), var12);
            }
        }
    }
}
 
開發者ID:alibaba,項目名稱:atlas,代碼行數:38,代碼來源:DexPatchPackageTask.java

示例9: getAbiSoFiles

import org.apache.commons.io.filefilter.TrueFileFilter; //導入依賴的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

示例10: copyLocalNativeLibraries

import org.apache.commons.io.filefilter.TrueFileFilter; //導入依賴的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

示例11: createTPatchFile

import org.apache.commons.io.filefilter.TrueFileFilter; //導入依賴的package包/類
private File createTPatchFile(File outPatchDir, File patchTmpDir) throws IOException {
    // 首先壓縮主bundle,先判斷主bundle裏有沒有文件
    File mainBundleFoder = new File(patchTmpDir, ((TpatchInput)input).mainBundleName);
    File mainBundleFile = new File(patchTmpDir, ((TpatchInput)input).mainBundleName + ".so");
    if (FileUtils.listFiles(mainBundleFoder, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE)
        .size() > 0) {
        hasMainBundle = true;
        CommandUtils.exec(mainBundleFoder, "zip -r " + mainBundleFile.getAbsolutePath() + " . -x */ -x .*");
    }
    FileUtils.deleteDirectory(mainBundleFoder);

    // 再壓縮各自的bundle
    File patchFile = null;

        patchFile = new File(outPatchDir,
                "patch-" + input.newApkBo.getVersionName() + "@" + input.baseApkBo.getVersionName() + ".tpatch");
    if (patchFile.exists()) {
        FileUtils.deleteQuietly(patchFile);
    }
    //        zipBundle(patchTmpDir, patchFile);
    CommandUtils.exec(patchTmpDir, "zip -r " + patchFile.getAbsolutePath() + " . -x */ -x .*");
    FileUtils.deleteDirectory(patchTmpDir);
    return patchFile;
}
 
開發者ID:alibaba,項目名稱:atlas,代碼行數:25,代碼來源:TPatchTool.java

示例12: getListFileMap

import org.apache.commons.io.filefilter.TrueFileFilter; //導入依賴的package包/類
/**
 * 將指定文件夾下的文件轉換為map
 *
 * @param folder
 * @return
 * @throws PatchException
 */
private Map<String, FileDef> getListFileMap(File folder) throws PatchException, IOException {
    Map<String, FileDef> map = new HashMap<String, FileDef>();
    if (!folder.exists() || !folder.isDirectory()) {
        throw new PatchException("The input folder:" + folder.getAbsolutePath()
                                     + " does not existed or is not a directory!");
    }
    Collection<File> files = FileUtils.listFiles(folder, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE);
    for (File file : files) {
        String path = PathUtils.toRelative(folder, file.getAbsolutePath());
        String md5 = MD5Util.getFileMD5String(file);
        FileDef fileDef = new FileDef(md5, path, file);
        map.put(path, fileDef);
    }
    return map;
}
 
開發者ID:alibaba,項目名稱:atlas,代碼行數:23,代碼來源:PatchFileBuilder.java

示例13: listFiles

import org.apache.commons.io.filefilter.TrueFileFilter; //導入依賴的package包/類
public void listFiles(JSONObject response) throws JSONException, IOException {
	File canonicalDir = destDir.getCanonicalFile();
	int uriDirectoryLength = canonicalDir.toURI().toString().length();
	JSONArray jArray = new JSONArray();
	
	for (File f : FileUtils.listFiles(canonicalDir, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE)) {
		File canonnicalF = f.getCanonicalFile();
		JSONObject jObj = new JSONObject();
		jObj.put("uri", URLDecoder.decode(canonnicalF.toURI().toString().substring(uriDirectoryLength), "UTF-8"));
		jObj.put("date", canonnicalF.lastModified());
		jObj.put("size", canonnicalF.length());
		jArray.put(jObj);
	}
	response.put("files", jArray);
	response.put("date", destDir.lastModified());
}
 
開發者ID:convertigo,項目名稱:convertigo-engine,代碼行數:17,代碼來源:MobileResourceHelper.java

示例14: list

import org.apache.commons.io.filefilter.TrueFileFilter; //導入依賴的package包/類
@Override
public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException {
    try {
        final AttributedList<Path> children = new AttributedList<Path>();
        final IRODSFileSystemAO fs = session.getClient();
        final IRODSFile f = fs.getIRODSFileFactory().instanceIRODSFile(directory.getAbsolute());
        if(!f.exists()) {
            throw new NotfoundException(directory.getAbsolute());
        }
        for(File file : fs.getListInDirWithFileFilter(f, TrueFileFilter.TRUE)) {
            final String normalized = PathNormalizer.normalize(file.getAbsolutePath(), true);
            if(StringUtils.equals(normalized, directory.getAbsolute())) {
                continue;
            }
            final PathAttributes attributes = new PathAttributes();
            final ObjStat stats = fs.getObjStat(file.getAbsolutePath());
            attributes.setModificationDate(stats.getModifiedAt().getTime());
            attributes.setCreationDate(stats.getCreatedAt().getTime());
            attributes.setSize(stats.getObjSize());
            attributes.setChecksum(Checksum.parse(Hex.encodeHexString(Base64.decodeBase64(stats.getChecksum()))));
            attributes.setOwner(stats.getOwnerName());
            attributes.setGroup(stats.getOwnerZone());
            children.add(new Path(directory, PathNormalizer.name(normalized),
                    file.isDirectory() ? EnumSet.of(Path.Type.directory) : EnumSet.of(Path.Type.file),
                    attributes));
            listener.chunk(directory, children);
        }
        return children;
    }
    catch(JargonException e) {
        throw new IRODSExceptionMappingService().map("Listing directory {0} failed", e, directory);
    }
}
 
開發者ID:iterate-ch,項目名稱:cyberduck,代碼行數:34,代碼來源:IRODSListService.java

示例15: normalizeCommands

import org.apache.commons.io.filefilter.TrueFileFilter; //導入依賴的package包/類
/**
 * Normalize all guild commands
 * @param collection All commands
 * @throws ConfigurationException If apache config throws an exception
 */
private static void normalizeCommands(Collection<Command> collection) throws ConfigurationException {
	Collection<File> found = FileUtils.listFiles(new File("resources/guilds"),
			TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE);
	found.add(new File("resources/guilds/template.properties"));
	for (File f : found) {
		if (f.getName().equals("GuildProperties.properties") || f.getName().equals("template.properties")) {
			PropertiesConfiguration config = new PropertiesConfiguration(f);
			List<String> enabledCommands = config.getList("EnabledCommands").stream()
					.map(object -> Objects.toString(object, null))
					.collect(Collectors.toList());
			List<String> disabledCommands = config.getList("DisabledCommands").stream()
					.map(object -> Objects.toString(object, null))
					.collect(Collectors.toList());
			for (Command c : collection) {
				if (!enabledCommands.contains(c.toString()) && !disabledCommands.contains(c.toString())) {
					enabledCommands.add(c.toString());
				}
			}
			config.setProperty("EnabledCommands", enabledCommands);
			config.save();
		}
	}
}
 
開發者ID:paul-io,項目名稱:momo-2,代碼行數:29,代碼來源:CommandHandler.java


注:本文中的org.apache.commons.io.filefilter.TrueFileFilter類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。