code: public static void makeSecurityCheck( final File    file,
                                            final File    base )
      {
          if( ! file.getAbsolutePath().startsWith( base.getAbsolutePath() ) )
          {
              throw new IllegalArgumentException( "Illegal file path [" + file + "]" );
          }
      }
docs: Check to make sure the user has not put .. anywhere in the path to allow overwriting
  of system files. Throws IllegalArgumentException if it fails the check.
  
  @param file file to check
  @param base base directory to compare it to.