boolean (File dir, File file) { final String dirPath = FileUtilRt.toCanonicalPath(dir.getAbsolutePath(), File.separatorChar, false); final String filePath = FileUtilRt.toCanonicalPath(file.getAbsolutePath(), File.separatorChar, false); final boolean trailingSlash = dirPath.endsWith("/"); if (filePath.length() < (trailingSlash? dirPath.length() : dirPath.length() + 1)) { return false; } if (!filePath.regionMatches(!isFileSystemCaseSensitive, 0, dirPath, 0, dirPath.length())) { return false; } if (!trailingSlash && filePath.charAt(dirPath.length()) != '/') { return false; } return true; }