本文整理汇总了Java中org.apache.commons.io.FileUtils.isFileOlder方法的典型用法代码示例。如果您正苦于以下问题:Java FileUtils.isFileOlder方法的具体用法?Java FileUtils.isFileOlder怎么用?Java FileUtils.isFileOlder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.io.FileUtils
的用法示例。
在下文中一共展示了FileUtils.isFileOlder方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: clearOldFiles
import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
/**
* Recursively delete files in {@code f} that were last used
* {@code millisAgo} milliseconds ago. On {@code android-21} and newer, this
* is based on the last access of the file, on older Android versions, it is
* based on the last time the file was modified, e.g. downloaded.
*
* @param f The file or directory to clean
* @param millisAgo The number of milliseconds old that marks a file for deletion.
*/
public static void clearOldFiles(File f, long millisAgo) {
if (f == null) {
return;
}
long olderThan = System.currentTimeMillis() - millisAgo;
if (f.isDirectory()) {
File[] files = f.listFiles();
if (files == null) {
return;
}
for (File file : files) {
clearOldFiles(file, millisAgo);
}
f.delete();
} else if (Build.VERSION.SDK_INT < 21) {
if (FileUtils.isFileOlder(f, olderThan)) {
f.delete();
}
} else {
CleanCacheService21.deleteIfOld(f, olderThan);
}
}
示例2: genetatePage
import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
private void genetatePage(App app, Template template) {
File file = new File(config.getAppDetailGenerateBasePath() + "/" + (app.getId() / 500) + "/" + app.getId()
+ ".html");
if (!file.exists()
|| FileUtils.isFileOlder(file, app.geteUpdateDate() == null ? new Date() : app.geteUpdateDate())) {
GenerateHelper.generateAppDetail(file, app, template, config);
logger.debug(String.format("new genetate app ID:%d, Name:%s, path:%s ", app.getId(), app.getName(),
file.getPath()));
}
}
示例3: genetatePageVelocity
import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
@SuppressWarnings("unused")
private void genetatePageVelocity(App app, org.apache.velocity.Template template) {
File file = new File(config.getAppDetailGenerateBasePath() + "/" + (app.getId() / 500) + "/" + app.getId()
+ ".html");
if (!file.exists()
|| FileUtils.isFileOlder(file, app.geteUpdateDate() == null ? new Date() : app.geteUpdateDate())) {
GenerateHelper.generateAppDetailByTemplate(file, app, template);
logger.debug(String.format("new genetate app ID:%d, Name:%s, path:%s ", app.getId(), app.getName(),
file.getPath()));
}
}
示例4: genetatePageVelocity
import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
private void genetatePageVelocity(App app, org.apache.velocity.Template template, Catalog catalog,
Map<Integer, Permissions> permissionsMap, List<AppTags> appTags, List<AppTags> AppTopic, boolean isAll) {
// 过滤掉一些东西
// 更新字段 过滤
String updateInfo = app.getUpdateInfo();
if (StringUtils.isNotEmpty(updateInfo)) {
updateInfo = updateInfo.replaceAll("\r\n", "<br />").replaceAll("\n", "<br />");
updateInfo = updateInfo.replaceAll("\\\\n", "");
app.setUpdateInfo(updateInfo);
}
String description = app.getDescription();
if (StringUtils.isNotEmpty(description)) {
description = description.replaceAll("\r\n", "<br />").replaceAll("\n", "<br />");
description = description.replaceAll("\\\\n", "");
app.setDescription(description);
}
StringBuilder detailPath = new StringBuilder();
detailPath.append("/").append(app.getId() / 500).append("/").append(app.getId()).append(".html");
File file = new File(config.getAppDetailGenerateBasePath() + detailPath.toString());
// if (StringUtils.isEmpty(app.getPageUrl())) {
// 设置url
app.setPageUrl(config.getAppPageBaseUrl() + detailPath.toString());
// }
// 根据分类查找对应的大游戏集合
List<BigGamePack> bigGameList = bigGamePackDao.getBigGameByMarkAppId(app.getMarketAppId());
// 如果 是取倒是,则不用判断 原文件是否存在 ,一律全部重新生成
if (isAll) {
GenerateHelper.generateAppDetailByTemplate(file, app, template, catalog, permissionsMap, appTags, AppTopic,
bigGameList);
dao.updatePageUrl(app);// 需要时才更新 db
return;
}
// 如果模板的最后 修改时间 比 应用 新,则需要全部重新生成 ,而不用应用 判断 文件 是否存在
if (!file.exists() || FileUtils.isFileOlder(file, template.getLastModified())
|| FileUtils.isFileOlder(file, app.getLastFetchTime() == null ? new Date() : app.getLastFetchTime())
|| FileUtils.isFileOlder(file, app.getLastUpdateTime() == null ? new Date() : app.getLastUpdateTime())) {
GenerateHelper.generateAppDetailByTemplate(file, app, template, catalog, permissionsMap, appTags, AppTopic,
bigGameList);
dao.updatePageUrl(app);// 需要时才更新 db
}
}
示例5: loadFile
import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
protected Collection<File> loadFile(FhirContext theCtx, String theSpecUrl, String theFilepath, boolean theCacheFile) throws IOException {
String userHomeDir = System.getProperty("user.home");
File applicationDir = new File(userHomeDir + File.separator + "." + "hapi-fhir-cli");
FileUtils.forceMkdir(applicationDir);
Collection<File> inputFiles;
if (isNotBlank(theFilepath)) {
ourLog.info("Loading from local path: {}", theFilepath);
if (theFilepath.startsWith("~" + File.separator)) {
theFilepath = userHomeDir + theFilepath.substring(1);
}
File suppliedFile = new File(FilenameUtils.normalize(theFilepath));
if (suppliedFile.isDirectory()) {
inputFiles = FileUtils.listFiles(suppliedFile, new String[]{"zip"}, false);
} else {
inputFiles = Collections.singletonList(suppliedFile);
}
} else {
File cacheDir = new File(applicationDir, "cache");
FileUtils.forceMkdir(cacheDir);
File inputFile = new File(cacheDir, "examples-json-" + theCtx.getVersion().getVersion() + ".zip");
Date cacheExpiryDate = DateUtils.addHours(new Date(), -12);
if (!inputFile.exists() | (theCacheFile && FileUtils.isFileOlder(inputFile, cacheExpiryDate))) {
File exampleFileDownloading = new File(cacheDir, "examples-json-" + theCtx.getVersion().getVersion() + ".zip.partial");
HttpGet get = new HttpGet(theSpecUrl);
CloseableHttpClient client = HttpClientBuilder.create().build();
CloseableHttpResponse result = client.execute(get);
if (result.getStatusLine().getStatusCode() != 200) {
throw new CommandFailureException("Got HTTP " + result.getStatusLine().getStatusCode() + " response code loading " + theSpecUrl);
}
ourLog.info("Downloading from remote url: {}", theSpecUrl);
downloadFileFromInternet(result, exampleFileDownloading);
FileUtils.deleteQuietly(inputFile);
FileUtils.moveFile(exampleFileDownloading, inputFile);
if (!theCacheFile) {
inputFile.deleteOnExit();
}
ourLog.info("Successfully Loaded example pack ({})", FileUtils.byteCountToDisplaySize(FileUtils.sizeOf(inputFile)));
IOUtils.closeQuietly(result.getEntity().getContent());
}
inputFiles = Collections.singletonList(inputFile);
}
return inputFiles;
}