List of usage examples for java.io File lastModified
public long lastModified()
From source file:com.jaeksoft.searchlib.ClientCatalog.java
public static final boolean receive_file_exists(Client client, String filePath, long lastModified, long length) throws IOException { File existsFile = new File(client.getDirectory(), filePath); if (!existsFile.exists()) return false; if (existsFile.lastModified() != lastModified) return false; if (existsFile.length() != length) return false; File rootDir = getTempReceiveDir(client); File targetFile = new File(rootDir, filePath); FileUtils.copyFile(existsFile, targetFile); return true;//from w w w. ja v a2 s. c om }
From source file:net.jcreate.xkins.XkinsLoader.java
/** * Agrega el archivo con su time stamp actual * @param url//from ww w . ja v a 2s . c om */ public static void addConfigFilesTimeStamp(URL url) { File file = new File(url.getFile()); getConfigFilesTimeStamp().put(file.getPath(), new Long(file.lastModified())); }
From source file:com.depas.utils.FileUtils.java
public static long getLastModifiedTime(String filePath) { File f = new File(filePath); if (f.exists()) { return f.lastModified(); } else {/*from w w w . jav a 2 s. c o m*/ return 0; } }
From source file:com.github.ipaas.ifw.front.FisResource.java
/** * ??map.json//from w ww .j a v a2 s .c o m * * @param namespace * @return * @throws FisException */ private static boolean register(String resMappingFileDir, String namespace) throws FisException { String mappingFileName = "map.json"; if (namespace != FisResource.DEFAULT_NS_GLOBAL) { mappingFileName = namespace + "-map.json"; } String mappingFileFullPath = resMappingFileDir + "/" + mappingFileName; // ?? BufferedReader br = null; try { String fileName = FisResource.class.getClassLoader().getResource(mappingFileFullPath).getPath(); File mapJsonFile = new File(fileName); if (null == lastModifiedTimes.get(fileName) || lastModifiedTimes.get(fileName) != mapJsonFile.lastModified()) { ObjectMapper mapper = new ObjectMapper(); resMap.put(namespace, mapper.readValue(mapJsonFile, HashMap.class)); // ?lastModifiedTime lastModifiedTimes.put(fileName, mapJsonFile.lastModified()); } return true; } catch (Exception e) { throw new FisException("map json??", e); } finally { if (br != null) { try { br.close(); } catch (IOException e) { } } } }
From source file:com.wavemaker.common.util.IOUtils.java
public static long getMostRecentModificationTime(File f, String... excludes) { if (!f.exists()) { throw new IllegalArgumentException("File doesn't exist: " + f); }/*from w ww . j av a2 s . c om*/ if (f.isFile()) { return f.lastModified(); } else { long rtn = -1; for (String s : f.list()) { for (String exclude : excludes) { if (s.equals(exclude)) { continue; } } File f2 = new File(f, s); long l = getMostRecentModificationTime(f2); if (l > rtn) { rtn = l; } } return rtn; } }
From source file:com.inrista.loggliest.Loggly.java
private static File oldestLogFile() { File dir = mContext.getDir(LOG_FOLDER, Context.MODE_PRIVATE); File[] files = dir.listFiles(); if (files == null || files.length == 0) { return null; }//w w w. ja va2 s . c o m File file = files[0]; for (int i = 1; i < files.length; i++) { if (file.lastModified() > files[i].lastModified()) { file = files[i]; } } return file; }
From source file:com.twosigma.beaker.core.rest.FileIORest.java
private static List<Map<String, Object>> getChildren(String path, List<String> openFolders) { File f = new File(path); File[] children = f.listFiles(); List<Map<String, Object>> ret = new ArrayList<>(children.length); for (File cf : children) { if (!cf.isHidden()) { String childPath = cf.getPath(); Map<String, Object> map = new HashMap<>(); map.put("uri", childPath); map.put("modified", cf.lastModified()); map.put("type", cf.isDirectory() ? "directory" : getMimeTypeForFileName(cf.getPath())); String prettyChildPath = childPath + "/"; if (openFolders.contains(prettyChildPath)) { map.put("children", getChildren(childPath, openFolders)); }//from www .jav a2 s . c o m ret.add(map); } } return ret; }
From source file:com.inrista.loggliest.Loggly.java
private static File recentLogFile() { File dir = mContext.getDir(LOG_FOLDER, Context.MODE_PRIVATE); File[] files = dir.listFiles(); if (files == null || files.length == 0) { return null; }//from ww w .ja v a2 s . c o m File file = files[0]; for (int i = 1; i < files.length; i++) { if (file.lastModified() < files[i].lastModified()) { file = files[i]; } } return file; }
From source file:gov.nih.nci.restgen.util.GeneratorUtil.java
private static void add(File source, JarOutputStream target) throws IOException { BufferedInputStream in = null; try {/*w w w . j av a 2s . c o m*/ if (source.isDirectory()) { String name = source.getPath().replace("\\", "/"); if (!name.isEmpty()) { if (!name.endsWith("/")) name += "/"; JarEntry entry = new JarEntry(name); entry.setTime(source.lastModified()); target.putNextEntry(entry); target.closeEntry(); } for (File nestedFile : source.listFiles()) add(nestedFile, target); return; } JarEntry entry = new JarEntry(source.getPath().replace("\\", "/")); entry.setTime(source.lastModified()); target.putNextEntry(entry); in = new BufferedInputStream(new FileInputStream(source)); byte[] buffer = new byte[1024]; while (true) { int count = in.read(buffer); if (count == -1) break; target.write(buffer, 0, count); } target.closeEntry(); } finally { if (in != null) in.close(); } }
From source file:dk.netarkivet.common.utils.Settings.java
/** * Reloads the settings. This will reload the settings from disk, and forget * all settings that were set with {@link #set} * * The field {@link #lastModified} is updated to timestamp of the settings * file that has been changed most recently. * * @throws IOFailure if settings cannot be loaded * @see #conditionalReload()// www . j a v a 2 s. c o m */ public static synchronized void reload() { lastModified = 0; List<File> settingsFiles = getSettingsFiles(); List<SimpleXml> simpleXmlList = new ArrayList<SimpleXml>(); for (File settingsFile : settingsFiles) { if (settingsFile.isFile()) { simpleXmlList.add(new SimpleXml(settingsFile)); } else { log.warn("The file '" + settingsFile.getAbsolutePath() + "' is not a file, and therefore not loaded"); } if (settingsFile.lastModified() > lastModified) { lastModified = settingsFile.lastModified(); } } synchronized (fileSettingsXmlList) { fileSettingsXmlList.clear(); fileSettingsXmlList.addAll(simpleXmlList); } }