public static String findCodeBaseInClassPath(Pattern codeBaseNamePattern,String classPath){
  if (classPath == null) {
    return null;
  }
  StringTokenizer tok=new StringTokenizer(classPath,File.pathSeparator);
  while (tok.hasMoreTokens()) {
    String t=tok.nextToken();
    File f=new File(t);
    Matcher m=codeBaseNamePattern.matcher(f.getName());
    if (m.matches()) {
      return t;
    }
  }
  return null;
}

public static String findCodeBaseInClassPath ( Pattern codeBaseNamePattern , String classPath ) { if ( classPath == null ) { return null ; } StringTokenizer tok = new StringTokenizer ( classPath , File . pathSeparator ) ; while ( tok . hasMoreTokens ( ) ) { String t = tok . nextToken ( ) ; File f = new File ( t ) ; Matcher m = codeBaseNamePattern . matcher ( f . getName ( ) ) ; if ( m . matches ( ) ) { return t ; } } return null ; }
try to find a codebase matching the given pattern in the given class path string .
