public static boolean isAncestor( File ancestorCandidate, File file ) {

		String path = ancestorCandidate.getAbsolutePath();
		if( ! path.endsWith( "/" ))
			path += "/";

		return file.getAbsolutePath().startsWith( path );
	}
public static boolean isAncestor ( File ancestorCandidate , File file ) { String path = ancestorCandidate . getAbsolutePath ( ) ; if ( ! path . endsWith ( "/" ) ) path += "/" ; return file . getAbsolutePath ( ) . startsWith ( path ) ; }
Determines whether a directory contains a given file.
@param ancestorCandidate the directory
@param file the file
@return true if the directory directly or indirectly contains the file