本文整理汇总了Java中org.apache.commons.io.FileUtils.isFileNewer方法的典型用法代码示例。如果您正苦于以下问题:Java FileUtils.isFileNewer方法的具体用法?Java FileUtils.isFileNewer怎么用?Java FileUtils.isFileNewer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.io.FileUtils
的用法示例。
在下文中一共展示了FileUtils.isFileNewer方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startCaching
import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
/**
* Parse all of the locally installed APKs into a memory cache, starting
* with the currently selected apps. APKs that are already parsed in the
* {@code index.jar} file will be read from that file.
*/
public static void startCaching(Context context) {
File indexJarFile = LocalRepoManager.get(context).getIndexJar();
PackageManager pm = context.getPackageManager();
for (ApplicationInfo applicationInfo : pm.getInstalledApplications(0)) {
if (applicationInfo.publicSourceDir.startsWith(FDroidApp.SYSTEM_DIR_NAME)) {
continue;
}
if (!indexJarFile.exists()
|| FileUtils.isFileNewer(new File(applicationInfo.sourceDir), indexJarFile)) {
parseApp(context, applicationInfo.packageName);
}
}
}
示例2: copyNewFile
import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
/**
* 拷贝源文件夹至目标文件夹
* 只拷贝新文件
* @param sourceFolder
* @param targetFolder
*/
public static void copyNewFile(String sourceFolder, String targetFolder){
try{
File sourceF = new File(sourceFolder);
if(!targetFolder.endsWith("/")) targetFolder=targetFolder+"/";
if (sourceF.exists()){
File[] filelist = sourceF.listFiles();
for(File f:filelist){
File targetFile = new File(targetFolder+f.getName());
if( f.isFile()){
//如果目标文件比较新,或源文件比较新,则拷贝,否则跳过
if(!targetFile.exists() || FileUtils.isFileNewer(f, targetFile)){
FileUtils.copyFileToDirectory(f, new File(targetFolder));
////System.out.println("copy "+ f.getName());
}else{
// //System.out.println("skip "+ f.getName());
}
}
}
}
}catch(Exception e){
e.printStackTrace();
throw new RuntimeException("copy file error");
}
}
示例3: accept
import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
/**
* Checks to see if the last modification of the file matches cutoff
* favorably.
* <p>
* If last modification time equals cutoff and newer files are required,
* file <b>IS NOT</b> selected.
* If last modification time equals cutoff and older files are required,
* file <b>IS</b> selected.
*
* @param file the File to check
* @return true if the filename matches
*/
@Override
public boolean accept(File file) {
boolean newer = FileUtils.isFileNewer(file, cutoff);
return acceptOlder ? !newer : newer;
}