question: private static boolean isChildOf ( File f , String dirName ) { try { File dir = new File ( dirName ) ; String canonicalDirName = dir . getCanonicalPath ( ) ; if ( ! canonicalDirName . endsWith ( File . separator ) ) { canonicalDirName += File . separator ; } String canonicalFileName = f . getCanonicalPath ( ) ; return canonicalFileName . startsWith ( canonicalDirName ) ; } catch ( IOException e ) { return false ; } }
target:  Checks whether given file resides inside give directory.