public static String formatPath(String absWebappsPath,String contextDirName){
  StringBuilder path=new StringBuilder(absWebappsPath.length() + contextDirName.length());
  path.append(absWebappsPath);
  if (log.isTraceEnabled()) {
    log.trace("Path start: {}",path.toString());
  }
  int idx=-1;
  if (File.separatorChar != '/') {
    while ((idx=path.indexOf(File.separator)) != -1) {
      path.deleteCharAt(idx);
      path.insert(idx,'/');
    }
  }
  if (log.isTraceEnabled()) {
    log.trace("Path step 1: {}",path.toString());
  }
  if ((idx=path.indexOf("./")) != -1) {
    path.delete(idx,idx + 2);
  }
  if (log.isTraceEnabled()) {
    log.trace("Path step 2: {}",path.toString());
  }
  if (path.charAt(path.length() - 1) != '/') {
    path.append('/');
  }
  if (log.isTraceEnabled()) {
    log.trace("Path step 3: {}",path.toString());
  }
  if (contextDirName.charAt(0) == '/' && path.charAt(path.length() - 1) == '/') {
    path.append(contextDirName.substring(1));
  }
 else {
    path.append(contextDirName);
  }
  if (log.isTraceEnabled()) {
    log.trace("Path step 4: {}",path.toString());
  }
  return path.toString();
}

public static String formatPath ( String absWebappsPath , String contextDirName ) { StringBuilder path = new StringBuilder ( absWebappsPath . length ( ) + contextDirName . length ( ) ) ; path . append ( absWebappsPath ) ; if ( log . isTraceEnabled ( ) ) { log . trace ( "Path start: {}" , path . toString ( ) ) ; } int idx = - 1 ; if ( File . separatorChar != '/' ) { while ( ( idx = path . indexOf ( File . separator ) ) != - 1 ) { path . deleteCharAt ( idx ) ; path . insert ( idx , '/' ) ; } } if ( log . isTraceEnabled ( ) ) { log . trace ( "Path step 1: {}" , path . toString ( ) ) ; } if ( ( idx = path . indexOf ( "./" ) ) != - 1 ) { path . delete ( idx , idx + 2 ) ; } if ( log . isTraceEnabled ( ) ) { log . trace ( "Path step 2: {}" , path . toString ( ) ) ; } if ( path . charAt ( path . length ( ) - 1 ) != '/' ) { path . append ( '/' ) ; } if ( log . isTraceEnabled ( ) ) { log . trace ( "Path step 3: {}" , path . toString ( ) ) ; } if ( contextDirName . charAt ( 0 ) == '/' && path . charAt ( path . length ( ) - 1 ) == '/' ) { path . append ( contextDirName . substring ( 1 ) ) ; } else { path . append ( contextDirName ) ; } if ( log . isTraceEnabled ( ) ) { log . trace ( "Path step 4: {}" , path . toString ( ) ) ; } return path . toString ( ) ; }
quick - n - dirty directory formatting to support launching in windows , specifically from ant .
