code: public static boolean isInSubDirectory(File dir, File file)
      {
          if (file == null)
              return false;
  
          if (file.equals(dir))
              return true;
  
          return isInSubDirectory(dir, file.getParentFile());
      }
docs: Returns true if "file" is a subfile or subdirectory of "dir".
  
  For example with the directory /path/to/a, the following return values would occur:
  
  /path/to/a/foo.txt - true /path/to/a/bar/zoo/boo/team.txt - true /path/to/b/foo.txt - false