Java tutorial
//package com.java2s; import java.io.File; public class Main { /** * Returns true if any {@code roots} combined with {@code rootSuffix} equals {@code canonicalPath} * @param roots to check * @param rootSuffix to add to the end of each {@code roots} when evaluating * @param canonicalPath to match * @return true if any {@code roots} combined with {@code rootSuffix} equals {@code canonicalPath} */ private static boolean reachedRoot(File[] roots, String rootSuffix, String canonicalPath) { for (File root : roots) { if (canonicalPath.equals(root.getPath() + rootSuffix)) { return true; } } return false; } }