本文整理汇总了Java中java.io.File.lastModified方法的典型用法代码示例。如果您正苦于以下问题:Java File.lastModified方法的具体用法?Java File.lastModified怎么用?Java File.lastModified使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.io.File
的用法示例。
在下文中一共展示了File.lastModified方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleOnChange
import java.io.File; //导入方法依赖的package包/类
/**
* On change event
*/
void handleOnChange(File logFile) {
try {
long lastModif = logFile.lastModified();
if (lastModif > logFileLastModified) {
logFileLastModified = lastModif;
logger.debug("Reload log4j configuration from "
+ logFile.getAbsolutePath());
new PropertyConfigurator().doConfigure(
logFile.getAbsolutePath(),
LogManager.getLoggerRepository());
logFileWarning = false;
}
} catch (Exception e) {
if (!logFileWarning) {
logFileWarning = true;
logger.error(logFile.getAbsolutePath(), e);
}
}
}
示例2: isFileTimeOut
import java.io.File; //导入方法依赖的package包/类
/**
* 检查当前目录的指定文件是否已经超过缓存时间
*
* @param file 待检测文件
*
* @return true: 超时; false:还没有超时
*/
private boolean isFileTimeOut(File file) {
if (file == null) {
return false;
}
if (mDirPerFileCacheTime_ms == UN_LIMT_STORE_TIME) {
return false;
}
if (System.currentTimeMillis() - file.lastModified() > mDirPerFileCacheTime_ms) {
return true;
}
return false;
}
示例3: getFirstPlayed
import java.io.File; //导入方法依赖的package包/类
public long getFirstPlayed() {
Player player = getPlayer();
if (player != null) return player.getFirstPlayed();
net.minecraft.nbt.NBTTagCompound data = getBukkitData();
if (data != null) {
if (data.hasKey("firstPlayed")) {
return data.getLong("firstPlayed");
} else {
File file = getDataFile();
return file.lastModified();
}
} else {
return 0;
}
}
示例4: getDawnVersion
import java.io.File; //导入方法依赖的package包/类
/**
* Looks at installed features, gets newest uk.ac.diamond.dawn.product.feature
* and returns that version.
*
* @return null if cannot find a dawn feature (might happen in debug mode)
*/
public static String getDawnVersion() {
final File dir = new File(getEclipseHome(), "features");
if (!dir.exists()) return null;
final File[] fa = dir.listFiles();
long date = -1;
String version = null;
for (File sd : fa) {
if (!sd.isDirectory()) continue;
Matcher matcher = FEATURE_MATCH.matcher(sd.getName());
if (matcher.matches()) {
if (date<sd.lastModified()) {
date = sd.lastModified();
version = matcher.group(1);
}
}
}
return version;
}
示例5: convert
import java.io.File; //导入方法依赖的package包/类
@Override
public String convert(FileHandle itemHandle, String file, String extension) throws Exception
{
if( disableConversion )
{
throw new RuntimeApplicationException("Conversion service is disabled");
}
ConversionFile targetHandle = new ConversionFile(itemHandle);
String targetFile = file + '.' + extension;
File source = fileSystemService.getExternalFile(itemHandle, file);
File target = fileSystemService.getExternalFile(targetHandle, targetFile);
if( !target.exists() || source.lastModified() > target.lastModified() )
{
LOGGER.info("Converting " + file + " to '" + extension + '\'');
target.getParentFile().mkdirs();
if( target.exists() )
{
fileSystemService.removeFile(targetHandle, targetFile);
}
ExecResult exec = runService(source.getAbsolutePath(), target.getAbsolutePath());
exec.ensureOk();
}
else if( LOGGER.isDebugEnabled() )
{
LOGGER.debug("Using cached conversion " + target.getAbsolutePath());
}
String relativePath = PathUtils.filePath(targetHandle.getMyPathComponent(), targetFile);
if( LOGGER.isDebugEnabled() )
{
LOGGER.debug("Converted path is " + relativePath);
}
return relativePath;
}
示例6: compileClass
import java.io.File; //导入方法依赖的package包/类
@Before
public void compileClass() throws IOException {
Set<File> classes = searchFile(new SuffixFilter("class"), dir);
Map<String, File> name2file = new Hashtable<>(classes.size());
for (File classFile : classes) {
name2file.put(classFile.getAbsolutePath(), classFile);
}
Set<File> srcs = searchFile(new SuffixFilter("java"), dir);
StringBuilder names = new StringBuilder(), paths = new StringBuilder();
for (File src : srcs) {
String classLocation = src.getAbsolutePath().substring(0, src.getAbsolutePath().length() - "java".length()) + "class";
if (name2file.containsKey(classLocation)) {
if (name2file.get(classLocation).lastModified() > src.lastModified()) {
System.out.println("Cached: " + src.getName());
continue;
}
}
names.append(" ").append(src.getName());
paths.append(" ").append(src.getAbsolutePath());
}
String clazzes = paths.toString();
if (!clazzes.equals("")) {
System.out.println("Compile: " + names.toString());
BatchCompiler.compile(
"-classpath rt.jar -g -warn:-unused -noExit -1.8 " + clazzes + " -d " + dir.getAbsolutePath(),
new PrintWriter(System.out),
new PrintWriter(System.err), null);
}
}
示例7: getFileLastModified
import java.io.File; //导入方法依赖的package包/类
/**
* 获取文件最后修改的毫秒时间戳
*
* @param file 文件
* @return 文件最后修改的毫秒时间戳
*/
public static long getFileLastModified(File file) {
if (file == null) {
return -1;
}
return file.lastModified();
}
示例8: getTimeStamp
import java.io.File; //导入方法依赖的package包/类
private static long getTimeStamp(File archive) {
long timeStamp = archive.lastModified();
if (timeStamp == -1) {
return timeStamp - 1;
}
return timeStamp;
}
示例9: getValueAt
import java.io.File; //导入方法依赖的package包/类
public Object getValueAt(int row, int col) {
Resource r = (Resource)files.get(row);
if (col == _RESOURCE)
return r;
if (!r.isInetShortcut()) {
File f = new File(r.getPath());
switch (col) {
case 0: return f.getName();
case 1: MimeType mt = MimeTypesList.getMimeTypeForFile(f.getName());
if (mt != null) return mt.getLabel();
else return "unknown";
case 2: Date d = new Date(f.lastModified());
return d;/*Local.getDateString(d, java.text.DateFormat.SHORT) +" "+
Local.getTimeString(d);*/
case 3:return f.getPath();
}
}
else {
if (col == 0)
return r.getPath();
else if (col == 1)
return Local.getString("Internet shortcut");
else
return "";
}
return null;
}
示例10: getLastModified
import java.io.File; //导入方法依赖的package包/类
private long getLastModified(String uri) {
for (String resource : resources) {
if (resource != null && resource.length() > 0) {
String path = resource + uri;
if (isFile(path)) {
File file = new File(path);
if (file.exists()) {
return file.lastModified();
}
}
}
}
return start;
}
示例11: ProfilesConfigFile
import java.io.File; //导入方法依赖的package包/类
/**
* Loads the AWS credential profiles from the file. The reference to the file is specified as a
* parameter to the constructor.
*/
public ProfilesConfigFile(File file, ProfileCredentialsService credentialsService) throws
SdkClientException {
profileFile = ValidationUtils.assertNotNull(file, "profile file");
profileCredentialsService = credentialsService;
profileFileLastModified = file.lastModified();
allProfiles = loadProfiles(profileFile);
}
示例12: monitor
import java.io.File; //导入方法依赖的package包/类
/** This will monitor the files.
*/
private void monitor() {
long time = System.currentTimeMillis() - m_millis;
for (Iterator itr = m_files.iterator(); itr.hasNext(); ) {
String fileName = (String) itr.next();
File file = new File(fileName);
if (!file.exists())
continue;
if (file.isFile()) {
if (file.lastModified() > time) {
if (log.isDebugEnabled())
log.debug(fileName + " has been modified. The Cache will be flushed.");
m_cache.clear();
break;
}
} else if (file.isDirectory()) {
// Just monitor the files in the directory. We'll not be recursing thru the directory.
File[] files = file.listFiles();
for (int i = 0; i < files.length; i++) {
file = files[i];
if (file.isFile()) {
if (file.lastModified() > time) {
if (log.isDebugEnabled())
log.debug(file.getAbsolutePath() + " has been modified. The Cache will be flushed.");
m_cache.clear();
break;
}
}
}
}
}
}
示例13: fileModified
import java.io.File; //导入方法依赖的package包/类
/** Returns the time the named file was last modified. */
@Override
public final long fileModified(String name) throws IOException {
File file = new File(directory, name);
return file.lastModified();
}
示例14: expansionFilesUptoData
import java.io.File; //导入方法依赖的package包/类
boolean expansionFilesUptoData() {
File cacheFile = getFileDetailsCacheFile();
// Read data into an array or something...
Map<String, Long> fileDetailsMap = new HashMap<String, Long>();
if(cacheFile.exists()) {
try {
FileReader fileCache = new FileReader(cacheFile);
BufferedReader bufferedFileCache = new BufferedReader(fileCache);
List<String> lines = new ArrayList<String>();
String line = null;
while ((line = bufferedFileCache.readLine()) != null) {
lines.add(line);
}
bufferedFileCache.close();
for(String dataLine : lines)
{
GameActivity.Log.debug("Splitting dataLine => " + dataLine);
String[] parts = dataLine.split(",");
fileDetailsMap.put(parts[0], Long.parseLong(parts[1]));
}
}
catch(Exception e)
{
GameActivity.Log.debug("Exception thrown during file details reading.");
e.printStackTrace();
fileDetailsMap.clear();
}
}
for (OBBData.XAPKFile xf : OBBData.xAPKS) {
String fileName = Helpers.getExpansionAPKFileName(this, xf.mIsMain, xf.mFileVersion);
String fileForNewFile = Helpers.generateSaveFileName(this, fileName);
String fileForDevFile = Helpers.generateSaveFileNameDevelopment(this, fileName);
// check to see if time/data on files match cached version
// if not return false
File srcFile = new File(fileForNewFile);
File srcDevFile = new File(fileForDevFile);
long lastModified = srcFile.lastModified();
long lastModifiedDev = srcDevFile.lastModified();
if(!(srcFile.exists() && fileDetailsMap.containsKey(fileName) && lastModified == fileDetailsMap.get(fileName))
&&
!(srcDevFile.exists() && fileDetailsMap.containsKey(fileName) && lastModifiedDev == fileDetailsMap.get(fileName)))
return false;
}
return true;
}
示例15: DeprecatedRawLocalFileStatus
import java.io.File; //导入方法依赖的package包/类
DeprecatedRawLocalFileStatus(File f, long defaultBlockSize, FileSystem fs) {
super(f.length(), f.isDirectory(), 1, defaultBlockSize,
f.lastModified(), new Path(f.getPath()).makeQualified(fs.getUri(),
fs.getWorkingDirectory()));
}