code: public static boolean fileInsideDirectory(final File dir, final File file) {
          checkNotNull("dir", dir);
          checkNotNull("file", file);
  
          final String dirPath = getCanonicalPath(dir);
          final String filePath = getCanonicalPath(file);
          return filePath.startsWith(dirPath);
      }
docs: Checks if a given file is inside the given directory.
  
  @param dir
  Base directory - Cannot be <code>null</code>.
  @param file
  File - Cannot be <code>null</code>.
  
  @return If the file is inside the directory TRUE, else FALSE.