ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From umag...@apache.org
Subject cvs commit: jakarta-ant/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/taskdefs LoadFile.java
Date Sun, 17 Feb 2002 02:09:19 GMT
umagesh     02/02/16 18:09:19

  Modified:    proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/taskdefs
                        LoadFile.java
  Log:
  When passed through filters, the resulting size of the filtered data may be
  larger than the actual file size.  Keep reading till -1 is returned.
  
  Revision  Changes    Path
  1.5       +12 -5     jakarta-ant/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/taskdefs/LoadFile.java
  
  Index: LoadFile.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/sandbox/filterreaders/src/main/org/apache/tools/ant/taskdefs/LoadFile.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- LoadFile.java	16 Feb 2002 02:29:34 -0000	1.4
  +++ LoadFile.java	17 Feb 2002 02:09:19 -0000	1.5
  @@ -183,9 +183,6 @@
               final long len = srcFile.length();
               log("file size = "+len,Project.MSG_DEBUG);
               //discard most of really big files
  -            if (len > Integer.MAX_VALUE) {
  -                log("this file is far to big to load completely");
  -            }
               final int size=(int) len;
               //open up the file
               fis = new FileInputStream(srcFile);
  @@ -290,8 +287,18 @@
               }
           }
   
  -        final int bufferLength = instream.read(buffer);
  -        final String text = new String(buffer, 0, bufferLength);
  +        int bufferLength = 0;
  +        String text = null;
  +        while (bufferLength != -1) {
  +            bufferLength = instream.read(buffer);
  +            if (bufferLength != -1) {
  +                if (text == null) {
  +                    text = new String(buffer, 0, bufferLength);
  +                } else {
  +                    text += new String(buffer, 0, bufferLength);
  +                }
  +            }
  +        }
           return text;
       }
   
  
  
  

--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message