List of usage examples for java.io File lastModified
public long lastModified()
From source file:atg.tools.dynunit.test.util.FileUtil.java
/** * @see org.apache.commons.lang3.SerializationUtils#deserialize(java.io.InputStream) *//*from ww w . j a v a 2s . c o m*/ @Nullable @Deprecated @SuppressWarnings("unchecked") public static Map<String, Long> deserialize(@NotNull final File file, final long serialTtl) { if (file.exists() && file.lastModified() < System.currentTimeMillis() - serialTtl) { logger.debug("Deleting previous serial {} because it's older than {} ms", file.getPath(), serialTtl); file.delete(); } Map<String, Long> o = null; try { if (file.exists()) { final ObjectInputStream in = new ObjectInputStream(new FileInputStream(file)); try { o = (Map<String, Long>) in.readObject(); } finally { in.close(); } } } catch (Exception e) { logger.catching(e); } if (o == null) { o = new HashMap<String, Long>(); } return o; }
From source file:atg.tools.dynunit.test.util.FileUtil.java
private static void setConfigFileLastModified(final File configFile) { Validate.notNull(configFile);/*from w ww .j a v a 2s . c om*/ setConfigFileLastModified(configFile.getPath(), configFile.lastModified()); }
From source file:org.mycontroller.standalone.model.McTemplate.java
@JsonIgnore public static McTemplate get(String fileName) throws IllegalAccessException, IOException { File templateFile = FileUtils.getFile(AppProperties.getInstance().getTemplatesLocation() + fileName); return McTemplate.builder().extension(FilenameUtils.getExtension(templateFile.getCanonicalPath())) .canonicalPath(templateFile.getCanonicalPath()).name(templateFile.getCanonicalPath()) .lastModified(templateFile.lastModified()).size(templateFile.length()).build(); }
From source file:cn.fql.utility.FileUtility.java
/** * Return last modified time of specified file * * @param fileName file name/*w w w.j a va 2 s .co m*/ * @return last modified time long value */ public static long getLastModifiedTime(String fileName) { try { java.io.File f = new java.io.File(fileName); return f.lastModified(); } catch (Exception ex) { return -1; } }
From source file:Main.java
/** * Tests if the specified <code>File</code> is older than the reference * <code>File</code>.//w ww.j a va2s . c o m * * @param file the <code>File</code> of which the modification date must * be compared, must not be {@code null} * @param reference the <code>File</code> of which the modification date * is used, must not be {@code null} * @return true if the <code>File</code> exists and has been modified before * the reference <code>File</code> * @throws IllegalArgumentException if the file is {@code null} * @throws IllegalArgumentException if the reference file is {@code null} or doesn't exist */ public static boolean isFileOlder(File file, File reference) { if (reference == null) { throw new IllegalArgumentException("No specified reference file"); } if (!reference.exists()) { throw new IllegalArgumentException("The reference file '" + reference + "' doesn't exist"); } return isFileOlder(file, reference.lastModified()); }
From source file:Main.java
/** * Tests if the specified <code>File</code> is newer than the reference * <code>File</code>./*from ww w. j a v a2s . co m*/ * * @param file the <code>File</code> of which the modification date must * be compared, must not be {@code null} * @param reference the <code>File</code> of which the modification date * is used, must not be {@code null} * @return true if the <code>File</code> exists and has been modified more * recently than the reference <code>File</code> * @throws IllegalArgumentException if the file is {@code null} * @throws IllegalArgumentException if the reference file is {@code null} or doesn't exist */ public static boolean isFileNewer(File file, File reference) { if (reference == null) { throw new IllegalArgumentException("No specified reference file"); } if (!reference.exists()) { throw new IllegalArgumentException("The reference file '" + reference + "' doesn't exist"); } return isFileNewer(file, reference.lastModified()); }
From source file:name.npetrovski.jphar.DataEntry.java
/** * Create entry from file// w w w . java 2s . c om * */ public static DataEntry createFromFile(File file, Compression.Type compression) throws IOException { EntryManifest em = new EntryManifest(); em.setCompression(new Compression(compression)); em.setTimestamp((int) file.lastModified() / 1000); em.getPath().setName(file.toPath().toString().replace("\\", "/")); DataEntry entry = new DataEntry(em); entry.setSource(file.getCanonicalFile()); if (file.isDirectory()) { em.getCompression().setType(Compression.Type.NONE); } else { byte[] data = Files.readAllBytes(file.toPath()); CRC32 crc = new CRC32(); crc.update(data); em.setCRC32((int) crc.getValue()); em.setUncompressedSize(data.length); } return entry; }
From source file:com.owncloud.android.lib.testclient.TestActivity.java
private static String getFileLastModifTimeStamp(String storagePath) { File file = new File(storagePath); Long timeStampLong = file.lastModified() / 1000; return timeStampLong.toString(); }
From source file:net.mindengine.blogix.BlogixMain.java
private static Comparator<File> byLastModified() { return new Comparator<File>() { @Override//from w w w .ja va 2 s. co m public int compare(File fileA, File fileB) { int diff = (int) (fileB.lastModified() - fileA.lastModified()); if (diff == 0) { diff = fileB.getName().compareTo(fileA.getName()); } return diff; } }; }
From source file:com.ruesga.rview.misc.CacheHelper.java
public static long getFileCacheAge(Context context, Account account, String name) { File file = new File(getAccountCacheDir(context, account), name); if (file.exists()) { return file.lastModified(); }// ww w . j a v a 2s . c om return 0; }