當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。