Example usage for java.io File lastModified

List of usage examples for java.io File lastModified

Introduction

In this page you can find the example usage for java.io File lastModified.

Prototype

public long lastModified() 

Source Link

Document

Returns the time that the file denoted by this abstract pathname was last modified.

Usage

From source file:jp.co.opentone.bsol.linkbinder.view.logo.ProjectLogoManager.java

/**
 * ??(??)??.//  w w w.j  av  a  2s .c  om
 *
 * @param logoFile ??
 * @return (??)
 */
private ProjectLogo getLogoData(String logoFile) {
    ProjectLogo result = null;
    BufferedInputStream bis = null;

    try {
        File f = new File(logoFile);
        long lastModifiled = f.lastModified();
        byte[] imageData = new byte[(int) f.length()];
        bis = new BufferedInputStream(new FileInputStream(logoFile));
        bis.read(imageData);

        result = new ProjectLogo();
        result.setImage(imageData);
        result.setLastModified(lastModifiled);
    } catch (FileNotFoundException e) {
        log.warn("????? [" + logoFile + "]");
    } catch (IOException e) {
        log.error("File I/O error[" + logoFile + "]", e);
    } finally {
        if (bis != null) {
            try {
                bis.close();
            } catch (IOException e) {
                log.error("File close error.[" + logoFile + "]", e);
            }
        }
    }
    return result;
}

From source file:com.frederikam.gensokyobot.command.admin.UpdateCommand.java

@Override
public void onInvoke(Guild guild, TextChannel channel, Member invoker, Message message, String[] args) {
    try {//from w  w  w. j ava  2s  .c  o m
        File homeJar = new File(System.getProperty("user.home") + "/FredBoat-1.0.jar");

        //Must exist and not be too old
        if (homeJar.exists() && (System.currentTimeMillis() - homeJar.lastModified()) < MAX_JAR_AGE) {
            update(channel);
            return;
        } else {
            log.info("");
        }

        COMPILE_COMMAND.onInvoke(guild, channel, invoker, message, args);

        update(channel);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}

From source file:com.ev.export.AnnualPDFExporter.java

private void handleWriteException(Exception e, File exportFile) throws ExporterException {
    long timeSinceLastChange = System.currentTimeMillis() - exportFile.lastModified();
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("Time since last change of export destination: " + timeSinceLastChange);
    }/*from   www. ja  v a 2s . co m*/
    if (exportFile.exists() && timeSinceLastChange < EXPECTED_MAX_EXPORT_TIME) {
        exportFile.delete();
    }
    throw new ExporterException("Could not export data.", e);
}

From source file:common.web.servlets.StaticFilesServlet.java

@Override
protected long getLastModified(HttpServletRequest request) {
    String name = getResourceName(request.getPathInfo());
    if (name == null)
        return -1;
    File file = new File(realPath, name);
    if (file.exists()) {
        return file.lastModified();
    } else {// w w w .  j av  a 2  s .com
        if (logger.isDebugEnabled()) {
            logger.debug("resource not found:" + request.getPathInfo());
        }
        return -1;
    }
}

From source file:com.threewks.thundr.view.velocity.ServletContextResourceLoader.java

/**
 * Checks to see when a resource was last modified
 * //from   w  ww  .j a  v a 2 s .c o  m
 * @param resource Resource the resource to check
 * @return long The time when the resource was last modified or 0 if the file can't be read
 */
@Override
public long getLastModified(Resource resource) {
    String rootPath = servletContext.getRealPath("/");
    if (rootPath == null) {
        // rootPath is null if the servlet container cannot translate the
        // virtual path to a real path for any reason (such as when the
        // content is being made available from a .war archive)
        return 0;
    }

    File cachedFile = getCachedFile(rootPath, resource.getName());
    if (cachedFile.canRead()) {
        return cachedFile.lastModified();
    } else {
        return 0;
    }
}

From source file:io.stallion.assets.AssetsController.java

public Long getCurrentTimeStampForAssetFile(String path) {
    String filePath = Context.settings().getTargetFolder() + "/assets/" + path;
    Path pathObj = FileSystems.getDefault().getPath(filePath);
    File file = new File(filePath);
    Long ts = file.lastModified();
    return ts;/*from   w  w  w . j  a  v  a  2 s  .  c o m*/
}

From source file:net.pms.util.TempFileMgr.java

private void scan() {
    long now = System.currentTimeMillis();
    for (Iterator<File> it = files.keySet().iterator(); it.hasNext();) {
        File f = it.next();
        if (!f.exists()) {
            it.remove();//from   w ww .  j  a v a 2  s. c om
            continue;
        }
        if ((now - f.lastModified()) > files.get(f)) {
            it.remove();
            f.delete();
        }
    }
    try {
        dumpFile();
    } catch (IOException e) {
    }
}

From source file:cn.dreampie.common.plugin.lesscss.compiler.NodeJsLessCssCompiler.java

public void compile(LessSource input, File output, boolean force)
        throws IOException, LessException, InterruptedException {
    if (force || !output.exists() || output.lastModified() < input.getLastModifiedIncludingImports()) {
        String data = compile(input.getNormalizedContent());
        FileUtils.writeStringToFile(output, data, encoding);
    }/*w ww  .ja v  a  2 s .co  m*/
}

From source file:jobhunter.persistence.Persistence.java

@SuppressWarnings("unused")
private void updateLastMod(final File file, final InputStream in) throws IOException {
    this.lastModification = file.lastModified();
    this.md5sum = DigestUtils.md5(in);
}

From source file:com.streamsets.pipeline.stage.origin.remote.FTPAndSSHDUnitTest.java

private void populateFakeFileSystemFromReal(File absFile) throws Exception {
    for (File f : absFile.listFiles()) {
        if (f.isFile()) {
            addFileToFakeFileSystem(f.getAbsolutePath(), FileUtils.readFileToByteArray(f), f.lastModified());
        } else if (f.isDirectory()) {
            DirectoryEntry entry = new DirectoryEntry(f.getAbsolutePath());
            fakeFtpServer.getFileSystem().add(entry);
            populateFakeFileSystemFromReal(f);
        }//from  ww  w  .j  a  va 2  s  .  c  o  m
    }
}