In commons-compress TarArchiveEntry one can ask for the mode using getMode(), however this returns an int.
What is the best way to check if any of the execute bits (user, group, everyone) is set?
It can be done in one go, checking all three bits at once:
static boolean isExecutable(int mode) {
return (mode & 0111) != 0;
}
Where 0111
is an octal literal, which is extremely rare, so as an alternative that is clearer but longer:
static boolean isExecutable(int mode) {
int mask = 1 | (1 << 3) | (1 << 6);
return (mode & mask) != 0;
}