avalon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dona...@apache.org
Subject cvs commit: jakarta-avalon/src/java/org/apache/excalibur/io FileUtil.java
Date Mon, 23 Apr 2001 06:37:03 GMT
donaldp     01/04/22 23:37:03

  Modified:    src/java/org/apache/excalibur/io FileUtil.java
  Log:
  Updated so doesn't rely on deleted StringUtil
  
  Revision  Changes    Path
  1.2       +33 -2     jakarta-avalon/src/java/org/apache/excalibur/io/FileUtil.java
  
  Index: FileUtil.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon/src/java/org/apache/excalibur/io/FileUtil.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- FileUtil.java	2001/04/17 03:07:48	1.1
  +++ FileUtil.java	2001/04/23 06:37:03	1.2
  @@ -9,7 +9,6 @@
   
   import java.io.*;
   import java.net.URL;
  -import org.apache.avalon.util.StringUtil;
   
   /**
    * This class provides basic facilities for manipulating files.
  @@ -164,7 +163,7 @@
   
       public static String normalize( String location )
       {
  -        location = StringUtil.replaceSubString( location, "/./", "/" );
  +        location = replaceSubString( location, "/./", "/" );
   
           final StringBuffer sb = new StringBuffer();
   
  @@ -366,5 +365,37 @@
                   }
               }
           }
  +    }
  +
  +    /**
  +     * Replace substrings of one string with another string and return altered string.
  +     *
  +     * @param original input string
  +     * @param oldString the substring section to replace
  +     * @param newString the new substring replacing old substring section
  +     * @return converted string
  +     */
  +    private static String replaceSubString( final String original,
  +                                            final String oldString,
  +                                            final String newString )
  +    {
  +        final StringBuffer sb = new StringBuffer();
  +
  +        int end = original.indexOf( oldString );
  +        int start = 0;
  +        final int stringSize = oldString.length();
  +
  +        while( end != -1 )
  +        {
  +            sb.append( original.substring( start, end ) );
  +            sb.append( newString );
  +            start = end + stringSize;
  +            end = original.indexOf( oldString, start );
  +        }
  +
  +        end = original.length();
  +        sb.append( original.substring( start, end ) );
  +
  +        return sb.toString();
       }
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: avalon-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: avalon-dev-help@jakarta.apache.org


Mime
View raw message