Test.java Source code

Java tutorial

Introduction

Here is the source code for Test.java

Source

import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.attribute.DosFileAttributeView;

public class Test {
    public static void main(String[] args) throws Exception {
        Path path = FileSystems.getDefault().getPath("./file2.log");
        System.out.println("File Size:" + Files.size(path));
        System.out.println("Is Directory:" + Files.isDirectory(path));
        System.out.println("Is Regular File:" + Files.isRegularFile(path));
        System.out.println("Is Symbolic Link:" + Files.isSymbolicLink(path));
        System.out.println("Is Hidden:" + Files.isHidden(path));
        System.out.println("Last Modified Time:" + Files.getLastModifiedTime(path));
        System.out.println("Owner:" + Files.getOwner(path));

        DosFileAttributeView view = Files.getFileAttributeView(path, DosFileAttributeView.class);
        System.out.println("Archive  :" + view.readAttributes().isArchive());
        System.out.println("Hidden   :" + view.readAttributes().isHidden());
        System.out.println("Read-only:" + view.readAttributes().isReadOnly());
        System.out.println("System   :" + view.readAttributes().isSystem());

        view.setHidden(false);
    }

}