Is there a good way to determine if a file is executable in Java

Viewed 9185

I'm aware you can call

Runtime.getRuntime().exec(file);

and get an exception if it is not executable, however this is unsafe since running an executable can have side effects.

I guess just checking the extension is enough on Windows, but is there a way I can read the executable bit on *nix file systems?

What is the best way to find out if an file is executable in the OS?

3 Answers
Related