commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jeri...@apache.org
Subject cvs commit: jakarta-commons/fileupload/src/java/org/apache/commons/fileupload MultipartStream.java
Date Tue, 26 Nov 2002 04:13:50 GMT
jericho     2002/11/25 20:13:50

  Modified:    fileupload/src/java/org/apache/commons/fileupload
                        MultipartStream.java
  Log:
  - Use ByteArrayOutputStream to prevent memory consumption just like
     the same purpose of the previous StringBuffer use.
  
  Patched by Park Jongjin <ecogeo at dreamwiz.com>
  
  Revision  Changes    Path
  1.9       +9 -7      jakarta-commons/fileupload/src/java/org/apache/commons/fileupload/MultipartStream.java
  
  Index: MultipartStream.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/fileupload/src/java/org/apache/commons/fileupload/MultipartStream.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- MultipartStream.java	24 Nov 2002 03:14:41 -0000	1.8
  +++ MultipartStream.java	26 Nov 2002 04:13:50 -0000	1.9
  @@ -66,6 +66,7 @@
   import java.io.IOException;
   import java.io.InputStream;
   import java.io.OutputStream;
  +import java.io.ByteArrayOutputStream;
   
   
   /**
  @@ -413,8 +414,9 @@
       {
           int i = 0;
           byte b[] = new byte[1];
  +        // to support multi-byte characters
  +        ByteArrayOutputStream baos = new ByteArrayOutputStream();
           int sizeMax = HEADER_PART_SIZE_MAX;
  -        byte[] buf = new byte[sizeMax];
           int size = 0;
           while (i < 4)
           {
  @@ -437,10 +439,10 @@
               }
               if (size <= sizeMax)
               {
  -                buf[size] = b[0];
  +                baos.write(b[0]);
               }
           }
  -        return new String(buf, 0, tail);
  +        return baos.toString();
       }
   
   
  
  
  

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


Mime
View raw message