/**
  * Checks whether the given file is inside the given directory.
  *
  * @param file the file
  * @param directory the directory
  * @return {@literal true} if the file is in the directory (or any subdirectories), {@literal
  *     false} otherwise.
  */
 public static boolean isInDirectory2(File file, File directory) {
   try {
     return FilenameUtils.directoryContains(directory.getCanonicalPath(), file.getCanonicalPath());
   } catch (IOException e) { // NOSONAR
     return false;
   }
 }