/*
 * Copyright 2014 Frank Dietrich <Frank.Dietrich@gmx.li>.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package de.jugsaar.meeting9.nio2.fileattributes;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.attribute.BasicFileAttributes;

/**
 * 
 * @author Frank Dietrich <Frank.Dietrich@gmx.li>
 */
public class BasicFileAttributesDemo {

    public static void main(String[] args) {
        Path path = Paths.get("resources/lorem-ipsum.txt");
        BasicFileAttributes attr;
        try {
            attr = Files.readAttributes(path, BasicFileAttributes.class);
            String outFormat = "%-20s: %s%n";
            System.out.printf(outFormat, "creationTime", attr.creationTime());
            System.out.printf(outFormat, "lastAccessTime", attr.lastAccessTime());
            System.out.printf(outFormat, "lastModifiedTime", attr.lastModifiedTime());

            System.out.printf(outFormat, "isRegularFile", attr.isRegularFile());
            System.out.printf(outFormat, "isDirectory", attr.isDirectory());
            System.out.printf(outFormat, "isSymbolicLink", attr.isSymbolicLink());
            System.out.printf(outFormat, "size", attr.size());
        } catch (IOException ex) {
            System.err.println("failed to obtain BasicFileAttributes " + ex.getMessage());
        }

    }
}

@@ -617,17 +617,16 @@
 se.%0A */%0A
-%0A
 package 
@@ -723,16 +723,71 @@
 .Files;%0A
+import static java.nio.file.LinkOption.NOFOLLOW_LINKS;%0A
 import j
@@ -888,17 +888,38 @@
 tes;
+%0Aimport java.util.Map;
 %0A%0A/**%0A
+
  *
- 
 %0A * 
@@ -1831,24 +1831,369 @@
 ttr.size());
+%0A%0A            System.out.printf(%22%25n### bulk access to file attributes%25n%22);%0A            Map%3CString, Object%3E attrBulk;%0A            attrBulk = Files.readAttributes(path, %22basic:*%22, NOFOLLOW_LINKS);%0A            for (String key : attrBulk.keySet()) %7B%0A                System.out.printf(%22%25s:%25-16s: %25s%25n%22, %22basic%22, key, attrBulk.get(key));%0A            %7D
 %0A        %7D c

add example for bulk access to file attributes