package learn_to_code.java_api.io_and_nio.nio;

import java.nio.file.Files;
import java.nio.file.Path;

/**
 * Shows some methods which you can query from files.
 * Also note static class references used here. For more of this check out learn_to_code/java_api/lambdas
 */
public class FileParameters {
    public static void main(String[] args) {
        Path path = FilesCreatorNIO.createFiles()[0];

        checkAndPrint("Writable", Files::isWritable, path);
        checkAndPrint("Readable", Files::isReadable, path);
        checkAndPrint("Executable", Files::isExecutable, path);
        checkAndPrint("Symbolic Link", Files::isSymbolicLink, path);
        checkAndPrint("Regular file", Files::isRegularFile, path);
        checkAndPrint("Directory", Files::isDirectory, path);
    }

    private static void checkAndPrint(String checkName, BooleanByPathFuncInterface function, Path p) {
        if (function.check(p))
            System.out.println("File IS " + checkName );
        else
            System.out.println("File IS NOT " + checkName);
    }

    private interface BooleanByPathFuncInterface {
        boolean check(Path p);
    }
}

@@ -43,16 +43,45 @@
 nio;%0D%0A%0D%0A
+import java.io.IOException;%0D%0A
 import j
@@ -128,16 +128,69 @@
 e.Path;%0D
+%0Aimport java.nio.file.attribute.BasicFileAttributes;%0D
 %0A%0D%0A/**%0D%0A
@@ -486,24 +486,278 @@
 es()%5B0%5D;%0D%0A%0D%0A
+        System.out.println(%22File name: %22 + path.getFileName());%0D%0A        System.out.println(%22File path: %22 + path);%0D%0A        System.out.println(%22Absolute path: %22 + path.toAbsolutePath());%0D%0A        System.out.println(%22Parent dir: %22 + path.getParent());%0D%0A%0D%0A
         chec
@@ -1128,24 +1128,359 @@
 ry, path);%0D%0A
+%0D%0A        try %7B%0D%0A            BasicFileAttributes attr = Files.readAttributes(path, BasicFileAttributes.class);%0D%0A            System.out.println(%22File creation time: %22 + attr.creationTime());%0D%0A            System.out.println(%22File size: %22 + attr.size());%0D%0A        %7D catch (IOException e) %7B%0D%0A            e.printStackTrace();%0D%0A        %7D%0D%0A%0D%0A
     %7D%0D%0A%0D%0A   

Add some more data you can get to FileParameters class