Examples of lastAccessTime()


Examples of java.nio.file.attribute.BasicFileAttributes.lastAccessTime()

    BasicFileAttributes basicAttributes = Files.readAttributes(filePathRef, BasicFileAttributes.class);
    System.out.println("File infos");
    System.out.printf(">>> Creation Time: %s\n", basicAttributes.creationTime());
    System.out.printf(">>> Directory? %s\n", basicAttributes.isDirectory());
    System.out.printf(">>> File? %s\n", basicAttributes.isRegularFile());
    System.out.printf(">>> Last accessed on: %s\n", basicAttributes.lastAccessTime());
    System.out.printf(">>> Last modified on: %s\n", basicAttributes.lastModifiedTime());
    System.out.printf(">>> File size (bytes): %s\n", basicAttributes.size());
    System.out.printf(">>> File key : %s\n", basicAttributes.fileKey());
    File tempDir = new File(System.getProperty("java.io.tmpdir"));
    Path tempDirPathRef = Paths.get(tempDir.toURI());
View Full Code Here

Examples of java.nio.file.attribute.BasicFileAttributes.lastAccessTime()

      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

Examples of java.nio.file.attribute.BasicFileAttributes.lastAccessTime()

      public boolean accept(File file) {
        try {
          Long now = new Date().getTime();
          Path path = Paths.get(file.getAbsolutePath());
          BasicFileAttributes attrs = Files.readAttributes(path, BasicFileAttributes.class);
          Long inBetween = now - attrs.lastAccessTime().toMillis();

          if (inBetween > retentionTime) {
            return true;
          }
View Full Code Here

Examples of java.nio.file.attribute.BasicFileAttributes.lastAccessTime()

    FileTimeTester(Path path) throws IOException {
      this.path = path;

      BasicFileAttributes attrs = attrs();
      accessTime = attrs.lastAccessTime();
      modifiedTime = attrs.lastModifiedTime();
    }

    private BasicFileAttributes attrs() throws IOException {
      return Files.readAttributes(path, BasicFileAttributes.class);
View Full Code Here

Examples of java.nio.file.attribute.BasicFileAttributes.lastAccessTime()

    BasicFileAttributes attrs = view.readAttributes();
    assertThat(attrs.fileKey()).isEqualTo(0);

    FileTime time = attrs.creationTime();
    assertThat(attrs.lastAccessTime()).isEqualTo(time);
    assertThat(attrs.lastModifiedTime()).isEqualTo(time);

    view.setTimes(null, null, null);

    attrs = view.readAttributes();
View Full Code Here

Examples of java.nio.file.attribute.BasicFileAttributes.lastAccessTime()

    view.setTimes(null, null, null);

    attrs = view.readAttributes();
    assertThat(attrs.creationTime()).isEqualTo(time);
    assertThat(attrs.lastAccessTime()).isEqualTo(time);
    assertThat(attrs.lastModifiedTime()).isEqualTo(time);

    view.setTimes(FileTime.fromMillis(0L), null, null);

    attrs = view.readAttributes();
View Full Code Here

Examples of java.nio.file.attribute.BasicFileAttributes.lastAccessTime()

    view.setTimes(FileTime.fromMillis(0L), null, null);

    attrs = view.readAttributes();
    assertThat(attrs.creationTime()).isEqualTo(time);
    assertThat(attrs.lastAccessTime()).isEqualTo(time);
    assertThat(attrs.lastModifiedTime()).isEqualTo(FileTime.fromMillis(0L));
  }

  @Test
  public void testAttributes() {
View Full Code Here

Examples of java.nio.file.attribute.BasicFileAttributes.lastAccessTime()

    Path bar = path("/bar");
    Files.copy(foo, bar, COPY_ATTRIBUTES);

    BasicFileAttributes attributes = Files.readAttributes(bar, BasicFileAttributes.class);
    assertThat(attributes.lastModifiedTime()).isEqualTo(FileTime.fromMillis(100));
    assertThat(attributes.lastAccessTime()).isEqualTo(FileTime.fromMillis(1000));
    assertThat(attributes.creationTime()).isEqualTo(FileTime.fromMillis(10000));
    assertThat(Files.getAttribute(bar, "owner:owner")).isEqualTo(zero);

    Path baz = path("/baz");
    Files.copy(foo, baz);
View Full Code Here

Examples of java.nio.file.attribute.BasicFileAttributes.lastAccessTime()

    Files.copy(foo, baz);

    // test that attributes are not copied when COPY_ATTRIBUTES is not specified
    attributes = Files.readAttributes(baz, BasicFileAttributes.class);
    assertThat(attributes.lastModifiedTime()).isNotEqualTo(FileTime.fromMillis(100));
    assertThat(attributes.lastAccessTime()).isNotEqualTo(FileTime.fromMillis(1000));
    assertThat(attributes.creationTime()).isNotEqualTo(FileTime.fromMillis(10000));
    assertThat(Files.getAttribute(baz, "owner:owner")).isNotEqualTo(zero);
  }

  @Test
View Full Code Here

Examples of java.nio.file.attribute.BasicFileAttributes.lastAccessTime()

      public boolean accept(File file) {
        try {
          Long now = new Date().getTime();
          Path path = Paths.get(file.getAbsolutePath());
          BasicFileAttributes attrs = Files.readAttributes(path, BasicFileAttributes.class);
          Long inBetween = now - attrs.lastAccessTime().toMillis();

          if (inBetween > retentionTime) {
            return true;
          }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.