private static boolean checkDirectory(@Nullable String directory) {
    if (directory == null) return false;
    try {
      Path path = Path.of(directory);
      return path.isAbsolute() && Files.isDirectory(path);
    }
    catch (InvalidPathException e) {
      return false;
    }
  }
private static boolean checkDirectory(@Nullable String directory)