ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ru...@apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs Replace.java
Date Mon, 21 May 2001 17:50:01 GMT
rubys       01/05/21 10:49:59

  Modified:    src/main/org/apache/tools/ant/taskdefs Replace.java
  Log:
  Fix an ArrayIndexOutOfBoundsException when building dom4j on Windows
  
  Revision  Changes    Path
  1.13      +6 -4      jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Replace.java
  
  Index: Replace.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Replace.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- Replace.java	2001/05/03 12:54:33	1.12
  +++ Replace.java	2001/05/21 17:49:54	1.13
  @@ -284,22 +284,24 @@
               BufferedReader br = new BufferedReader(new FileReader(src));
               BufferedWriter bw = new BufferedWriter(new FileWriter(temp));
   
  -            // read the entire file into a char[]
  +            // read the entire file into a StringBuffer
               //   size of work buffer may be bigger than needed
               //   when multibyte characters exist in the source file
  +            //   but then again, it might be smaller than needed on
  +            //   platforms like Windows where length can't be trusted
               int fileLengthInBytes = (int)(src.length());
  -            char[] tmpBuf = new char[fileLengthInBytes];
  +            StringBuffer tmpBuf = new StringBuffer(fileLengthInBytes);
               int readChar = 0;
               int totread = 0;
               while (true) {
                   readChar = br.read();
                   if (readChar < 0) { break; }
  -                tmpBuf[totread] = (char)readChar;
  +                tmpBuf.append((char)readChar);
                   totread++;
               }
   
               // create a String so we can use indexOf
  -            String buf = new String(tmpBuf);
  +            String buf = tmpBuf.toString();
   
               //Preserve original string (buf) so we can compare the result
               String newString = new String(buf);
  
  
  

Mime
View raw message