List of usage examples for java.io File lastModified
public long lastModified()
From source file:de.jwi.jfm.FileWrapper.java
public String getId() { String s = null;// ww w .j a v a2 s. c o m File file = getFile(); try { s = URLEncoder.encode(file.getName() + "." + Long.toString(file.lastModified()), "UTF-8"); } catch (UnsupportedEncodingException e) { } return s; }
From source file:com.asual.lesscss.LessResource.java
public long getLastModified() throws IOException { if (lastModified == null || !cache) { lastModified = super.getLastModified(); String content = new String(resource instanceof URL ? ResourceUtils.readTextUrl((URL) resource, charset) : ResourceUtils.readTextFile((File) resource, charset)); String folder = path.substring(0, path.lastIndexOf(System.getProperty("file.separator")) + 1); Pattern p = Pattern.compile("@import\\s+(\"[^\"]*\"|'[^']*')"); Matcher m = p.matcher(content); while (m.find()) { String path = folder + m.group(1).replaceAll("\"|'", ""); File includedFile = new File(path); if (!includedFile.exists()) { includedFile = new File(path + ".less"); }/*from w w w . j a va 2s.c o m*/ long importLastModified = includedFile.lastModified(); if (importLastModified > lastModified) { lastModified = importLastModified; } } } logger.debug("getLastModified() in LessResource: " + lastModified); return lastModified; }
From source file:corner.hadoop.services.impl.LocalFileAccessorProxy.java
@Override public FileDesc getFileDesc(String filePath) throws IOException { File file = new File(addRootPath(filePath)); if (file.exists()) { return new FileDesc(file.getAbsolutePath(), file.isDirectory(), new Timestamp(file.lastModified()), file.length());/*from w ww . j a va 2 s .c om*/ } else { return null; } }
From source file:com.blackducksoftware.tools.scmconnector.integrations.ftp.FTPConnector.java
private void downloadFiles(String parentPath, FTPClient client, FTPFile folder) throws IllegalStateException, FileNotFoundException, IOException, FTPIllegalReplyException, FTPException, FTPDataTransferException, FTPAbortedException, FTPListParseException { client.changeDirectory(folder.getName()); File dir = new File(parentPath, folder.getName()); if (!dir.exists()) { dir.mkdir();/* w w w . j av a2 s . co m*/ } FTPFile[] list = client.list(); deleteFileInTargetDirectoryNotExistingInSource(dir, list); for (FTPFile f : list) { if (f.getType() == FTPFile.TYPE_FILE) { File targetFile = new File(dir.getPath(), f.getName()); if (f.getModifiedDate().getTime() != targetFile.lastModified()) { log.info("Obtaining file: " + f.getName()); client.download(f.getName(), targetFile); targetFile.setLastModified(f.getModifiedDate().getTime()); } } else if (f.getType() == FTPFile.TYPE_DIRECTORY) { log.info("Inspecting directory: " + f.getName()); downloadFiles(dir.getPath(), client, f); } } client.changeDirectoryUp(); }
From source file:com.gmail.cjbooms.thesis.pythonappengine.server.FileSystemServiceImpl.java
/** * Create a list of all File details using File Wrapper * Determine if File is to be added based on displayHidden * @param files List of java file objects * @return wrappedFiles The list of wrapped files *//*from w w w . jav a2 s . co m*/ private FileWrapper[] buildFilesList(File[] files) { FileWrapper[] wrappedFiles = new FileWrapper[files.length]; int i = 0; for (File currentFile : files) { String path = currentFile.getAbsolutePath(); String fileName = currentFile.getName(); String modified = dateFormat(currentFile.lastModified()); if (!(fileName.startsWith(".") && !displayHidden)) { wrappedFiles[i] = new FileWrapper(path, fileName, modified); if (files[i].isDirectory()) { wrappedFiles[i].setIsDirectory(); } i++; } } return wrappedFiles; }
From source file:com.sforce.cd.apexUnit.report.ApexReportGeneratorTest.java
@Test public void generateTestReportTest() { TestStatusPollerAndResultHandler queryPollerAndResultHandler = new TestStatusPollerAndResultHandler(); Long justBeforeReportGeneration = System.currentTimeMillis(); ApexReportBean[] apexReportBeans = queryPollerAndResultHandler.fetchResultsFromParentJobId(parentJobId, conn);/*from w w w . j a va 2s.c o m*/ CodeCoverageComputer toolingAPIInvoker = new CodeCoverageComputer(); ApexClassCodeCoverageBean[] apexClassCodeCoverageBeans = toolingAPIInvoker .calculateAggregatedCodeCoverageUsingToolingAPI(); String reportFileName = "ApexUnitReport.xml"; ApexUnitTestReportGenerator.generateTestReport(apexReportBeans, reportFileName); File reportFile = new File(reportFileName); LOG.info("justBeforeReportGeneration: " + justBeforeReportGeneration); LOG.info("reportFile last modified..: " + reportFile.lastModified()); LOG.info("Result:" + FileUtils.isFileNewer(reportFile, justBeforeReportGeneration)); Assert.assertTrue(FileUtils.isFileNewer(reportFile, justBeforeReportGeneration)); }
From source file:corner.hadoop.services.impl.LocalFileAccessorProxy.java
@Override public List<FileDesc> list(String dirPath) throws IOException { String _path = addRootPath(dirPath); if (dirPath.endsWith(File.separator)) { _path = dirPath.substring(0, dirPath.length() - 1); }// www . j a v a2s. c o m File dir = new File(_path); if (!dir.isDirectory()) { throw new IllegalArgumentException("The path [" + dirPath + "] is not dir."); } File[] files = dir.listFiles(); if (files != null && files.length > 0) { List<FileDesc> ret = new LinkedList<FileDesc>(); for (File file : files) { ret.add(new FileDesc(_path + File.separator + file.getName(), file.isDirectory(), new Timestamp(file.lastModified()), file.length())); } return ret; } return null; }
From source file:com.germinus.easyconf.FileConfigurationChangedReloadingStrategy.java
/** * Check if the configuration has changed since the last time it was loaded. *///from w w w . j ava2 s.com protected boolean hasChanged() { File file = getFile(); if (!file.exists()) { if (log.isDebugEnabled()) { log.debug("File does not exist: " + file); } return false; } boolean result = (file.lastModified() > lastModified); lastChecked = System.currentTimeMillis(); return result; }
From source file:com.netxforge.oss2.config.ViewsDisplayFactory.java
private InputStream getStream() throws IOException { File viewsDisplayFile = getViewsDisplayFile(); m_lastModified = viewsDisplayFile.lastModified(); InputStream stream = new FileInputStream(viewsDisplayFile); return stream; }
From source file:com.eleybourn.bookcatalogue.backup.tar.TarBackupWriter.java
/** * Save a cover file//from ww w .j a v a2 s . c om */ @Override public void putCoverFile(File source) throws IOException { TarArchiveEntry entry = new TarArchiveEntry(source.getName()); entry.setModTime(source.lastModified()); entry.setSize(source.length()); mOutput.putArchiveEntry(entry); FileInputStream in = new FileInputStream(source); streamToArchive(in); }