本文整理汇总了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");
}
}
}
示例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") );
}
示例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);
}
}
}
示例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;
}
示例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()});
}
}
示例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());
}
}
示例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);
}
}
}
示例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);
}
}
}
}
示例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;
}
示例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);
}
}
示例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;
}
示例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;
}
示例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());
}
示例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);
}
}
示例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();
}
}
}