Пример #1
0
  public static boolean directoryContains(File directory, File child) throws IOException {
    if (directory == null) {
      throw new IllegalArgumentException("Directory must not be null");
    }
    if (!directory.isDirectory()) {
      throw new IllegalArgumentException("Not a directory: " + directory);
    }
    if (child == null) {
      return false;
    }
    if ((!directory.exists()) || (!child.exists())) {
      return false;
    }
    String canonicalParent = directory.getCanonicalPath();
    String canonicalChild = child.getCanonicalPath();

    return FilenameUtils.directoryContains(canonicalParent, canonicalChild);
  }