I would like to check whether an existing file is in a specific directory or a subdirectory of that.
I have two File objects.
File dir; File file; <
How about comparing the paths?
boolean areRelated = file.getAbsolutePath().contains(dir.getAbsolutePath()); System.out.println(areRelated);
or
boolean areRelated = child.getAbsolutePath().startsWith(parent.getAbsolutePath())