当前位置: 首页>>代码示例>>Java>>正文


Java File.lastModified方法代码示例

本文整理汇总了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);
        }
    }
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:23,代码来源:Initializer.java

示例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;
}
 
开发者ID:youmi,项目名称:nativead,代码行数:23,代码来源:AbsDownloadDir.java

示例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;
    }
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:18,代码来源:CraftOfflinePlayer.java

示例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;
}
 
开发者ID:eclipse,项目名称:scanning,代码行数:27,代码来源:BundleUtils.java

示例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;
}
 
开发者ID:equella,项目名称:Equella,代码行数:39,代码来源:Office2HtmlConversionServiceImpl.java

示例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);
    }
}
 
开发者ID:fxzjshm,项目名称:jvm-java,代码行数:30,代码来源:ClassFileTest.java

示例7: getFileLastModified

import java.io.File; //导入方法依赖的package包/类
/**
 * 获取文件最后修改的毫秒时间戳
 *
 * @param file 文件
 * @return 文件最后修改的毫秒时间戳
 */
public static long getFileLastModified(File file) {
    if (file == null) {
        return -1;
    }
    return file.lastModified();
}
 
开发者ID:imliujun,项目名称:LJFramework,代码行数:13,代码来源:FileUtils.java

示例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;
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:8,代码来源:MultiDexExtractor.java

示例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;
}
 
开发者ID:ser316asu,项目名称:Reinickendorf_SER316,代码行数:28,代码来源:ResourcesTable.java

示例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;
}
 
开发者ID:dachengxi,项目名称:EatDubbo,代码行数:15,代码来源:ResourceFilter.java

示例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);
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:12,代码来源:ProfilesConfigFile.java

示例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;
                    }
                }
            }
        }
    }
}
 
开发者ID:jaffa-projects,项目名称:jaffa-framework,代码行数:35,代码来源:CacheSourceMonitor.java

示例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();
}
 
开发者ID:GateNLP,项目名称:gate-core,代码行数:7,代码来源:FSDirectory.java

示例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;
}
 
开发者ID:FallingUpGame,项目名称:FallingUp,代码行数:50,代码来源:DownloaderActivity.java

示例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()));
}
 
开发者ID:naver,项目名称:hadoop,代码行数:6,代码来源:RawLocalFileSystem.java


注:本文中的java.io.File.lastModified方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。