This discussion is archived
1 Reply Latest reply: Feb 27, 2013 4:14 PM by rp0428 RSS

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

991511 Newbie
Currently Being Moderated
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!
  • 1. Re: How to apply the right permission "read" on a folder?
    rp0428 Guru
    Currently Being Moderated
    >
    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
    >
    You can't just make statements. You need to provide proof that supports what you are saying.

    Saying something is 'still not working' has NO meaning whatsoever. Post the exception and stack trace that you get.

    'always return true' - provide something that supports this

    You also need to post the code you are using, the full Java version and the full OS version.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points