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;
<
You can traverse File Tree starting from your specific DIR.
At Java 7, there is Files.walkFileTree
method. You have only to write your own visitor
to check if current node is searched file. More doc:
http://docs.oracle.com/javase/7/docs/api/java/nio/file/Files.html#walkFileTree%28java.nio.file.Path,%20java.util.Set,%20int,%20java.nio.file.FileVisitor%29