List of usage examples for java.io File lastModified
public long lastModified()
From source file:Main.java
static long getLastModified(final File f) { return ((Long) AccessController.doPrivileged(new PrivilegedAction() { public Object run() { return new Long(f.lastModified()); }/* w w w . j a v a 2 s .c o m*/ })).longValue(); }
From source file:com.cloud.servlet.StaticResourceServlet.java
static String getEtag(final File resource) { return "W/\"" + resource.length() + "-" + resource.lastModified(); }
From source file:name.martingeisse.ecobuild.util.EcobuildFileUtil.java
/** * Returns either the minimum or maximum timestamp of all files within the * specified root, which can either be a folder or a file. * @param root the root to start from//ww w . j a va 2 s . c om * @param max true to determine the maximum timestamp, false to determine the minimum timestamp * @return the timestamp */ public static long getMinMaxTimestampRecursively(File root, boolean max) { if (root.isDirectory()) { long timestamp = root.lastModified(); for (File sub : root.listFiles()) { timestamp = minMax(timestamp, sub.lastModified(), max); } return timestamp; } else { return root.lastModified(); } }
From source file:Main.java
private static void readGpxDirectory(File dir, final Map<String, Long> map, String parent, boolean absolutePath) { if (dir != null && dir.canRead()) { File[] files = dir.listFiles(); if (files != null) { for (File f : files) { if (f.getName().toLowerCase().endsWith(".gpx")) { //$NON-NLS-1$ map.put(absolutePath ? f.getAbsolutePath() : parent + f.getName(), f.lastModified()); } else if (f.isDirectory()) { readGpxDirectory(f, map, parent + f.getName() + "/", absolutePath); }//w w w.ja va2 s .co m } } } }
From source file:de.betterform.cache.CacheManager.java
public static Element getElementFromFileCache(File file) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("search xfFileCache for key: " + file.getAbsolutePath() + file.lastModified()); }//from w ww .ja v a2 s.com Element elem = xfFileCache.get(file.getAbsolutePath() + file.lastModified()); if (LOGGER.isDebugEnabled()) { LOGGER.debug(xfFileCache.getStatistics()); if (elem == null) { LOGGER.debug("no value found for key " + file.getAbsolutePath() + file.lastModified()); } else { LOGGER.debug("found value for key " + file.getAbsolutePath() + file.lastModified()); } } return elem; }
From source file:net.sf.jabref.exporter.AutoSaveManager.java
/** * Check if a newer autosave exists for the given file. * @param f The file to check./*www. j a v a 2s . c o m*/ * @return true if an autosave is found, and if the autosave is newer * than the given file. */ public static boolean newerAutoSaveExists(File f) { File asFile = AutoSaveManager.getAutoSaveFile(f); return asFile.exists() && (asFile.lastModified() > f.lastModified()); }
From source file:Main.java
public static int clearCacheFolder(File dir, long curTime) { int deletedFiles = 0; if (dir != null && dir.isDirectory()) { try {/*from ww w. j av a 2s.c om*/ for (File child : dir.listFiles()) { if (child.isDirectory()) { deletedFiles += clearCacheFolder(child, curTime); } if (child.lastModified() < curTime) { if (child.delete()) { deletedFiles++; } } } } catch (Exception e) { e.printStackTrace(); } } return deletedFiles; }
From source file:Main.java
private static int clearCacheFolder(File dir, long curTime) { int deletedFiles = 0; if (dir != null && dir.isDirectory()) { try {//ww w . j av a 2 s . c om for (File child : dir.listFiles()) { if (child.isDirectory()) { deletedFiles += clearCacheFolder(child, curTime); } if (child.lastModified() < curTime) { if (child.delete()) { deletedFiles++; } } } } catch (Exception e) { e.printStackTrace(); } } return deletedFiles; }
From source file:Main.java
/** * Try to cache parsed Templates, but check for changes on disk * @param src//from w ww. java2s . c o m * @return */ public static Templates getTemplates(File src) throws TransformerException { String key = src.getAbsolutePath(); if (XSL_MODIFIED.containsKey(key)) { // check to see if it has changed if (src.lastModified() <= XSL_MODIFIED.get(key).longValue()) { return TEMPLATES_CACHE.get(key); } } Templates template = getTransformerFactory().newTemplates(new StreamSource(src)); TEMPLATES_CACHE.put(key, template); XSL_MODIFIED.put(key, src.lastModified()); return template; }
From source file:Main.java
public static void zipChildren(File folder, String prefix, ZipOutputStream out) throws IOException { File[] files = folder.listFiles(); if (files == null) return;// www.j av a2s. c om for (File file : files) { if (file.isFile()) { String name = prefix + file.getName(); ZipEntry entry = new ZipEntry(name); entry.setTime(file.lastModified()); out.putNextEntry(entry); loadFromFile(file, out); out.closeEntry(); } else if (file.isDirectory()) { zipChildren(file, prefix + file.getName() + "/", out); } } }