Java Files get file attribute map not follow link

Description

Java Files get file attribute map not follow link

import java.nio.file.Files;
import java.nio.file.LinkOption;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Map;
import java.util.Set;

public class Main {

   public static void main(String[] args) throws Exception {
      Path path = Paths.get("Main.java");

      Map<String, Object> attrsMap = Files.readAttributes(path, "*", LinkOption.NOFOLLOW_LINKS); 
      Set<String> keys = attrsMap.keySet();

      for (String attribute : keys) {
         System.out.println(attribute + ": " + Files.getAttribute(path, attribute));
      }//from   w ww .j  a  v a2s .co  m

   }

}



PreviousNext

Related