List of usage examples for java.io File lastModified
public long lastModified()
From source file:de.inren.service.picture.PictureResource.java
protected Time getImageLastModified() { IRequestParameters params = RequestCycle.get().getRequest().getRequestParameters(); File file = getImageFile(params); if (file != null) { return Time.valueOf(new Date(file.lastModified())); }//ww w . j a v a 2 s.c om return null; }
From source file:FileTableDemo.java
public Object getValueAt(int row, int col) { File f = new File(dir, filenames[row]); switch (col) { case 0://from w ww . j a v a2s.c o m return filenames[row]; case 1: return new Long(f.length()); case 2: return new Date(f.lastModified()); case 3: return f.isDirectory() ? Boolean.TRUE : Boolean.FALSE; case 4: return f.canRead() ? Boolean.TRUE : Boolean.FALSE; case 5: return f.canWrite() ? Boolean.TRUE : Boolean.FALSE; default: return null; } }
From source file:com.globalsight.everest.webapp.pagehandler.projects.workflows.WorkflowHandlerHelper.java
private static String getPreviousQAReportFilePath(Workflow workflow) { StringBuilder sb = new StringBuilder(); sb.append(AmbFileStoragePathUtils.getReportsDir(workflow.getCompanyId())); sb.append(File.separator);//w w w .j a v a 2 s. co m sb.append(ReportConstants.REPORT_QA_CHECKS_REPORT); sb.append(File.separator); sb.append(workflow.getJob().getId()); sb.append(File.separator); sb.append(workflow.getTargetLocale().toString()); File file = new File(sb.toString()); long maxTime = 0; File emptyFile = null; String filePath = null; if (file.exists()) { File[] files = file.listFiles(); for (File fe : files) { long time = fe.lastModified(); if (time > maxTime) { maxTime = time; emptyFile = fe; } } long maxDate = 0; File emptyDownFile = null; if (emptyFile != null) { File[] downFiles = emptyFile.listFiles(); for (File f : downFiles) { long time = f.lastModified(); if (time > maxDate) { maxDate = time; emptyDownFile = f; } } if (emptyDownFile != null) { filePath = emptyDownFile.getPath(); } } } return filePath; }
From source file:com.lightbox.android.cache.ApiCache.java
@Override public Result<String> getFromDisk(String key, Object... objects) { Result<String> result = EMPTY_RESULT; if (key != null) { try {/*from ww w .jav a 2 s . c o m*/ File file = getFile(key); if (file.exists()) { long updatedTime = file.lastModified(); String string = FileUtils.readFileToString(file); result = new Result<String>(string, updatedTime); } } catch (IOException e) { Log.w(TAG, e); // Will return empty result } } return result; }
From source file:ca.flop.jpublish.dwr.demo.FilePing.java
/** * (non-Javadoc)/*from ww w . j a v a 2 s .c o m*/ * * @see java.lang.Runnable#run() */ public void run() { try { log.debug("FilePing: Starting server-side thread"); if (fileName != null && fileName.trim().length() > 0) while (active) { Collection sessions = sctx.getScriptSessionsByPage(requestUrl); Util pages = new Util(sessions); File file = new File(fileName); if (file.exists()) { fileTimeStamp = file.lastModified(); if (lastRead < fileTimeStamp) { pages.setValue("fileDisplay", read(fileName)); lastRead = fileTimeStamp; log.info("reading from: " + fileName + "..."); } } else { pages.setValue("fileDisplay", " File: " + fileName + ", not found!"); } log.debug("Sent message"); Thread.sleep(1000); } Collection sessions = sctx.getScriptSessionsByPage(requestUrl); Util pages = new Util(sessions); pages.setValue("fileDisplay", EMPTY_STRING); lastRead = 0L; log.debug("FilePing: Stopping server-side thread"); } catch (InterruptedException ex) { ex.printStackTrace(); } }
From source file:com.alibaba.simpleimage.CompositeImageProcessor.java
/** * ??????return false?? ?return true?// ww w . j a v a 2s . co m * * @param errorPath * @return */ private boolean canWriteErrorDir(File errorPath) { String[] files = errorPath.list(); if (files != null && files.length > FILE_CONTENT_LOG_MAX_FILE_NUM) { long now = System.currentTimeMillis(); int delNum = 0; for (String filename : files) { File errImg = new File(errorPath, filename); if (now - errImg.lastModified() > EXPIRED_PERIOD) { errImg.delete(); delNum++; } } if (files.length - delNum <= FILE_CONTENT_LOG_MAX_FILE_NUM) { return true; } return false; } return true; }
From source file:com.qwazr.utils.json.DirectoryJsonManager.java
protected void set(String name, T instance) throws IOException, ServerException { if (instance == null) return;/*from ww w . ja v a 2s. c o m*/ if (StringUtils.isEmpty(name)) return; rwl.writeLock().lock(); try { File destFile = getFile(name); JsonMapper.MAPPER.writeValue(destFile, instance); put(name, destFile.lastModified(), instance); buildCache(); } finally { rwl.writeLock().unlock(); } }
From source file:cc.kune.core.server.manager.file.EntityBackgroundDownloadManager.java
/** * Builds the response./*w ww . ja v a2 s . co m*/ * * @param statetoken * the statetoken * @param filename * the filename * @param mimeType * the mime type * @param imgsize * the imgsize * @param resp * the resp * @return the string * @throws FileNotFoundException * the file not found exception * @throws IOException * Signals that an I/O exception has occurred. */ String buildResponse(final StateToken statetoken, final String filename, final String mimeType, final ImageSize imgsize, final HttpServletResponse resp) throws FileNotFoundException, IOException { final String absDir = kuneProperties.get(KuneProperties.UPLOAD_LOCATION) + FileUtils.groupToDir(statetoken.getGroup()); String absFilename = absDir + filename; if (imgsize != null) { final String imgsizePrefix = "." + imgsize; final String extension = FileUtils.getFileNameExtension(filename, true); final String filenameWithoutExtension = FileUtils.getFileNameWithoutExtension(filename, extension); final String filenameResized = filenameWithoutExtension + imgsizePrefix + extension; if (fileUtils.exist(absDir + filenameResized)) { absFilename = absDir + filenameResized; } } final File file = new File(absFilename); lastModified = file.lastModified(); resp.setContentLength((int) file.length()); if (mimeType != null) { final String contentType = mimeType.toString(); resp.setContentType(contentType); LOG.info("Content type returned: " + contentType); } resp.setHeader(RESP_HEADER_CONTEND_DISP, RESP_HEADER_ATTACHMENT_FILENAME + filename + RESP_HEADER_END); CacheUtils.setCache1Day(resp); return absFilename; }
From source file:com.google.gwt.dev.resource.impl.ZipFileClassPathEntry.java
private ZipFileClassPathEntry(File zipFile) throws IOException { assert zipFile.isAbsolute(); this.lastModified = zipFile.lastModified(); this.zipFile = new ZipFile(zipFile); this.location = zipFile.toURI().toString(); }
From source file:it.tidalwave.northernwind.core.impl.util.CachedURIResolver.java
/******************************************************************************************************************* * ******************************************************************************************************************/ @Override/* w w w.j av a 2 s . c om*/ public Source resolve(final String href, final String base) throws TransformerException { try { log.info("resolve({}, {})", href, base); final File cacheFolder = new File(cacheFolderPath); if (!cacheFolder.exists()) { mkdirs(cacheFolder); } final File cachedFile = new File(cacheFolder, encodedUtf8(href)); final long elapsed = System.currentTimeMillis() - cachedFile.lastModified(); log.debug(">>>> cached file is {} elapsed time is {} msec", cachedFile, elapsed); if (!cachedFile.exists() || (elapsed > expirationTime)) { cacheDocument(cachedFile, href); } return new StreamSource(new FileInputStream(cachedFile)); } catch (IOException e) { throw new TransformerException(e); } }