public static boolean isDescendant ( File forParent , File potentialChild ) throws IOException { Path child = fileToPath ( potentialChild . getAbsoluteFile ( ) ) . normalize ( ) ; Path parent = fileToPath ( forParent . getAbsoluteFile ( ) ) . normalize ( ) ; return child . startsWith ( parent ) ; }
A check if a file path is a descendant of a parent path