Package java.nio.file.attribute

Examples of java.nio.file.attribute.BasicFileAttributes


        StringGroup modified = new StringGroup(files.length);

        try {
            int counter = 0;
            for(File file : files) {
                BasicFileAttributes attr = Files.readAttributes(file.toPath(), fileAttributes);

                access.addString(AeshPosixFilePermissions.toString(((PosixFileAttributes) attr)), counter);
                size.addString(String.valueOf(attr.size()), counter);
                if(Config.isOSPOSIXCompatible())
                    owner.addString(((PosixFileAttributes) attr).owner().getName(), counter);
                else
                    owner.addString("", counter);
                if(Config.isOSPOSIXCompatible())
                    group.addString(((PosixFileAttributes) attr).group().getName(), counter);
                else
                    owner.addString("", counter);
                modified.addString(DATE_FORMAT.format(new Date(attr.lastModifiedTime().toMillis())), counter);

                counter++;
            }
        }
        catch (IOException e) {
View Full Code Here


        StringGroup modified = new StringGroup(files.length);

        try {
            int counter = 0;
            for(File file : files) {
                BasicFileAttributes attr = Files.readAttributes(file.toPath(), fileAttributes);

                access.addString(AeshPosixFilePermissions.toString(((PosixFileAttributes) attr)), counter);
                size.addString(String.valueOf(attr.size()), counter);
                if(Config.isOSPOSIXCompatible())
                    owner.addString(((PosixFileAttributes) attr).owner().getName(), counter);
                else
                    owner.addString("", counter);
                if(Config.isOSPOSIXCompatible())
                    group.addString(((PosixFileAttributes) attr).group().getName(), counter);
                else
                    owner.addString("", counter);
                modified.addString(DATE_FORMAT.format(new Date(attr.lastModifiedTime().toMillis())), counter);

                counter++;
            }
        }
        catch (IOException e) {
View Full Code Here

            path = targetPath;
          }
        }
      }

      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;
      } else if (basic_attr.isSymbolicLink()) {
        type = ItemType.LINK;
      } else {
        type = ItemType.UNKNOWN;
      }
View Full Code Here

  }

  static Attributes getFileAttributesBasic(FS fs, File path) {
    try {
      Path nioPath = path.toPath();
      BasicFileAttributes readAttributes = nioPath
          .getFileSystem()
          .provider()
          .getFileAttributeView(nioPath,
              BasicFileAttributeView.class,
              LinkOption.NOFOLLOW_LINKS).readAttributes();
      Attributes attributes = new FileUtil.Java7BasicAttributes(fs, path,
          true,
          readAttributes.isDirectory(),
          fs.supportsExecute() ? path.canExecute() : false,
          readAttributes.isSymbolicLink(),
          readAttributes.isRegularFile(), //
          readAttributes.creationTime().toMillis(), //
          readAttributes.lastModifiedTime().toMillis(),
          readAttributes.isSymbolicLink() ? Constants
              .encode(FileUtils.readSymLink(path)).length
              : readAttributes.size());
      return attributes;
    } catch (NoSuchFileException e) {
      return new FileUtil.Java7BasicAttributes(fs, path, false, false,
          false, false, false, 0L, 0L, 0L);
    } catch (IOException e) {
View Full Code Here

      IncommingInspectionResult iirslt = new IncommingInspectionResult(getHostID(), getSessionID());
      IncommingDespatchConfirmation idc = new IncommingDespatchConfirmation(getHostID(), getSessionID());
      IncommingQMInspectionRequest iireq = new IncommingQMInspectionRequest(getHostID(), getSessionID());
      GenericMessageHeader gmh = new GenericMessageHeader();
      LinkedList<String> filenames = new LinkedList<String>();
      BasicFileAttributes attrs;
     
      while (true)
      {

        com.commander4j.util.JWait.milliSec(100);

        if (allDone)
        {
          if (dbconnected)
          {
            Common.hostList.getHost(hostID).disconnect(getSessionID());
          }
          return;
        }

        if (InboundMessageCollectionThread.recoveringFiles == false)
        {

          dir = new File(inputPath);

          chld = dir.listFiles((FileFilter) FileFileFilter.FILE);

          if (chld == null)
          {
            allDone = true;
          } else
          {
            Arrays.sort(chld, LastModifiedFileComparator.LASTMODIFIED_COMPARATOR);
            filenames.clear();

            for (int i = 0; (i < chld.length) & (i < maxfiles); i++)
            {
              fileName = chld[i].getName();
              try
              {
                attrs = Files.readAttributes(chld[i].getAbsoluteFile().toPath(), BasicFileAttributes.class);

                if (attrs.size() > 0)
                {
                  if (fileName.indexOf(".xml") > 0)
                  {
                    filenames.addFirst(fileName);
                    com.commander4j.util.JWait.milliSec(50);
View Full Code Here

        }
      }
      // ... or in the image file attributes
      if (imgDate == null) {
        Path path = img.toPath();
        BasicFileAttributes attr = Files.readAttributes(path, BasicFileAttributes.class);
        imgDate = new Date(attr.creationTime().toMillis());

      }
    }
    catch (Exception ex) {
      cfg.getCtxt().log("Failed to get image date: " + img.getAbsolutePath() + "\n", ex);
View Full Code Here

        }
      }
      // ... or in the image file attributes
      if (imgDate == null) {
        Path path = img.toPath();
        BasicFileAttributes attr = Files.readAttributes(path, BasicFileAttributes.class);
        imgDate = new Date(attr.creationTime().toMillis());

      }
    }
    catch (Exception ex) {
      cfg.getCtxt().log("Failed to get image date: " + img.getAbsolutePath() + "\n", ex);
View Full Code Here

        }
      }
      // ... or in the image file attributes
      if (imgDate == null) {
        Path path = img.toPath();
        BasicFileAttributes attr = Files.readAttributes(path, BasicFileAttributes.class);
        imgDate = new Date(attr.creationTime().toMillis());

      }
    }
    catch (Exception ex) {
      cfg.getCtxt().log("Failed to get image date: " + img.getAbsolutePath() + "\n", ex);
View Full Code Here

    Reads last-modified with proper failure handling if something goes wrong.
     */
    public static long getLastModified( File file ){
        try
        {
            BasicFileAttributes basicFileAttributes =
                Files.readAttributes( file.toPath(), BasicFileAttributes.class );
            return basicFileAttributes.lastModifiedTime().toMillis();
        }
        catch ( IOException e )
        {
            throw new RuntimeException( e );
        }
View Full Code Here

      @Override
      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

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

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.