fitgoodies-core/src/main/java/de/cologneintelligence/fitgoodies/file/FileSystemDirectoryHelper.java
public File getCommonDir(final File dir1, final File dir2) throws IOException {
		List<File> parts1 = getParentDirs(dir1);
		List<File> parts2 = getParentDirs(dir2);
		File matched = null;

		final int maxCommonSize = Math.min(parts1.size(), parts2.size());
		for (int i = 0; i < maxCommonSize; ++i) {
			if (parts1.get(i).equals(parts2.get(i))) {
				matched = parts1.get(i);
			} else {
				break;
			}
		}

		return matched;
	}
public File getCommonDir(final File dir1, final File dir2) throws IOException {
		List<File> parts1 = getParentDirs(dir1);
		List<File> parts2 = getParentDirs(dir2);
		File matched = null;

		final int maxCommonSize = Math.min(parts1.size(), parts2.size());
		for (int i = 0; i < maxCommonSize; ++i) {
			if (parts1.get(i).equals(parts2.get(i))) {
				matched = parts1.get(i);
			} else {
				break;
			}
		}

		return matched;
	}
Gets the longest common parent directory path of two paths.

@param dir1 first path
@param dir2 second path
@return longest common path in {@code dir1} and {@code dir2}
@throws java.io.IOException Exception which is thrown if paths cannot be normalized