I am using this code to test it;
public class CanExecuteTest {
public static void main (String[] args) {
File currentDir = new File(System.getProperty("user.dir"));
traverse(currentDir);
}
public static void traverse(File dir) {
String[] filesAndDirs = dir.list();
for (String fileOrDir : filesAndDirs) {
File f = new File(dir, fileOrDir);
if (f.isDirectory()) {
traverse(f);
} else {
System.out.print(f);
if (f.canExecute()) {
System.out.println(" can execute");
} else {
System.out.println(" cannot execute");
}
}
}
}
}
This outputs that every file is an executable file. Am I doing something wrong here, or is this a java bug? I am on windows 7, netbeans 7.3.1 and java 7.