本文整理匯總了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;
}