mkodad
mkodad

Reputation: 43

How to apply the right permission "read" on a folder?

How to apply the right permission "read" on a folder?

Hello,

Please, how can we apply the right permission "read" on a folder in a java class on Windows, and how can we know if we have the right to "read" on a folder or not? "read" of course

I tested with canRead() and setReadable(true) provided by the "File" class of "io" java, but it's still not working!

the canRead() method always returns true even if you have no right to "Read" on the folder.

the setReadable(true) method does not apply the right "read" on the folder

import java.io.File;

public class TestTest {
public static void main(String[] args) {
    File f = new File("D:/Test");
    if(f.canRead())
        System.out.println("OK => "+f.setWritable(true));
    else
        System.out.println("KO");
}
}

Are there solutions?

Thank you for your help!

Upvotes: 1

Views: 101

Answers (1)

Puce
Puce

Reputation: 38132

Have a look at the new NIO.2 File API:

http://docs.oracle.com/javase/tutorial/essential/io/fileAttr.html

Upvotes: 1

Related Questions