Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.attribute.FileAttribute;
import java.nio.file.attribute.PosixFileAttributeView;
import java.nio.file.attribute.PosixFileAttributes;
import java.nio.file.attribute.PosixFilePermission;
import java.nio.file.attribute.PosixFilePermissions;
import java.util.Set;

public class Main {

    public static void main(String[] args) throws Exception {

        Path path = Paths.get("c:/home/tutorial/Java/JavaFX/Topic.txt");
        Path new_path = Paths.get("/home/tutorial/Java/JavaFX/new_Topic.txt");

        //use of fromString
        Set<PosixFilePermission> permissions = PosixFilePermissions.fromString("rw-r--r--");
        try {
            Files.setPosixFilePermissions(new_path, permissions);
        } catch (IOException e) {
            System.err.println(e);
        }
    }
}