harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From odea...@apache.org
Subject svn commit: r1005084 - /harmony/enhanced/java/trunk/jdktools/modules/jdktools/src/main/java/org/apache/harmony/tools/jar/Main.java
Date Wed, 06 Oct 2010 15:20:19 GMT
Author: odeakin
Date: Wed Oct  6 15:20:18 2010
New Revision: 1005084

URL: http://svn.apache.org/viewvc?rev=1005084&view=rev
Log:
Creation of jar files will throw OutOfMemoryException when compressing large files. Change
the compression of files to use a 1024 byte buffer size (same as in the decompression code)
instead of attempting to allocate the full file size.

Modified:
    harmony/enhanced/java/trunk/jdktools/modules/jdktools/src/main/java/org/apache/harmony/tools/jar/Main.java

Modified: harmony/enhanced/java/trunk/jdktools/modules/jdktools/src/main/java/org/apache/harmony/tools/jar/Main.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/trunk/jdktools/modules/jdktools/src/main/java/org/apache/harmony/tools/jar/Main.java?rev=1005084&r1=1005083&r2=1005084&view=diff
==============================================================================
--- harmony/enhanced/java/trunk/jdktools/modules/jdktools/src/main/java/org/apache/harmony/tools/jar/Main.java
(original)
+++ harmony/enhanced/java/trunk/jdktools/modules/jdktools/src/main/java/org/apache/harmony/tools/jar/Main.java
Wed Oct  6 15:20:18 2010
@@ -320,9 +320,11 @@ public class Main {
         zos.putNextEntry(zEntry);
         // now write the data
         FileInputStream fis = new FileInputStream(file);
-        byte fileContent[] = new byte[(int)file.length()];
-        fis.read(fileContent);
-        zos.write(fileContent);
+        byte fileContent[] = new byte[1024];
+        int bytesRead;
+        while ((bytesRead = fis.read(fileContent)) != -1) {
+            zos.write(fileContent, 0, bytesRead);
+        }
         zos.closeEntry();
     }    
 }



Mime
View raw message