Package java.nio.file.attribute

Examples of java.nio.file.attribute.FileTime


  public static void writeToFileAndUpdateMTime(Path file, String contents) throws IOException {
    if(!file.toFile().exists()) {
      writeStringToFile(file, contents);
      return;
    }
    FileTime lastModifiedTime = Files.getLastModifiedTime(file);
    writeStringToFile(file, contents);
    // Make sure last modified time is different from before
    Files.setLastModifiedTime(file, FileTime.fromMillis(lastModifiedTime.toMillis() - 1_000));
  }
View Full Code Here


  public void markStale() {
    valueTimeStamp = null;
  }
 
  public synchronized boolean isStale() {
    FileTime lastModifiedTime;
    try {
      lastModifiedTime = Files.getLastModifiedTime(filePath);
    } catch (IOException e) {
      return true;
    }
   
    if(valueTimeStamp == null || valueTimeStamp.toMillis() < lastModifiedTime.toMillis()) {
      return true;
    }
    return false;
  }
View Full Code Here

  }
 
  public void updateValue(VALUE value, FileTime newTimeStampMaximum) {
    assertNotNull(newTimeStampMaximum);
   
    FileTime newValueTimeStamp;
    try {
      newValueTimeStamp = Files.getLastModifiedTime(filePath);
    } catch (IOException e) {
      newValueTimeStamp = FileTime.fromMillis(0);
    }
View Full Code Here

 
  protected void doUpdateManifestEntry(BundlePath bundlePath) throws ExecutionException {
    RunDubDescribeCallable dubDescribeTask = new RunDubDescribeCallable(bundlePath, false);
    DubBundleDescription bundleDesc = dubDescribeTask.submitAndGet(dubProcessAgent);
   
    FileTime dubStartTimeStamp = dubDescribeTask.getStartTimeStamp();
    DubDescribeAnalysis dubDescribeAnalyzer = new DubDescribeAnalysis(bundleDesc);
   
    setNewManifestEntry(dubStartTimeStamp, dubDescribeAnalyzer);
  }
View Full Code Here

            return false;
        try {
            Path extractedFile = appCache.resolve(".extracted");
            if (!Files.exists(extractedFile))
                return false;
            FileTime extractedTime = Files.getLastModifiedTime(extractedFile);

            Path jarFile = Paths.get(jar.getName());
            FileTime jarTime = Files.getLastModifiedTime(jarFile);

            return extractedTime.compareTo(jarTime) >= 0;
        } catch (IOException e) {
            throw new AssertionError(e);
        }
View Full Code Here

            return false;
        try {
            Path extractedFile = appCache.resolve(".extracted");
            if (!Files.exists(extractedFile))
                return false;
            FileTime extractedTime = Files.getLastModifiedTime(extractedFile);

            Path jarFile = Paths.get(jar.getName());
            FileTime jarTime = Files.getLastModifiedTime(jarFile);

            return extractedTime.compareTo(jarTime) >= 0;
        } catch (IOException e) {
            throw new AssertionError(e);
        }
View Full Code Here

            return false;
        try {
            Path extractedFile = appCache.resolve(".extracted");
            if (!Files.exists(extractedFile))
                return false;
            FileTime extractedTime = Files.getLastModifiedTime(extractedFile);

            Path jarFile = Paths.get(jar.getName());
            FileTime jarTime = Files.getLastModifiedTime(jarFile);

            return extractedTime.compareTo(jarTime) >= 0;
        } catch (IOException e) {
            throw new AssertionError(e);
        }
View Full Code Here

        }
      }

      BasicFileAttributes basic_attr = Files.readAttributes(path, BasicFileAttributes.class, LinkOption.NOFOLLOW_LINKS);
      final Long filesize = basic_attr.size();
      final FileTime creationTime = basic_attr.creationTime();
      final FileTime modifyTime = basic_attr.lastModifiedTime();
      final FileTime accessTime = basic_attr.lastAccessTime();

      if (basic_attr.isDirectory()) {
        type = ItemType.FOLDER;
      } else if (basic_attr.isRegularFile()) {
        type = ItemType.FILE;
View Full Code Here

        return FileSystems.getDefault().getPath(FS.separators(path));
    }

    public static void touch(Path path) throws IOException
    {
        FileTime now = FileTime.fromMillis(System.currentTimeMillis());
        Files.setLastModifiedTime(path,now);
    }
View Full Code Here

    @Override
    public long lastModified()
    {
        try
        {
            FileTime ft = Files.getLastModifiedTime(path,NO_FOLLOW_LINKS);
            return ft.toMillis();
        }
        catch (IOException e)
        {
            LOG.ignore(e);
            return 0;
View Full Code Here

TOP

Related Classes of java.nio.file.attribute.FileTime

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.