Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/361.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 将大型CSV流写入内存中的ZipOutStream是否会消耗与CSV或潜在zip大小相同的内存?_Java_Zip - Fatal编程技术网

Java 将大型CSV流写入内存中的ZipOutStream是否会消耗与CSV或潜在zip大小相同的内存?

Java 将大型CSV流写入内存中的ZipOutStream是否会消耗与CSV或潜在zip大小相同的内存?,java,zip,Java,Zip,我有一个包含大CSV的Zip。因此,它的拉链 我想在CSV中添加一列并再次压缩它 我可以将整个Zip存储在内存中,但绝对不能将整个CSV存储在内存中。因此,如果我将CSV块逐个块写入内存中ZipoutStream的特定ZipEntry。它是否会像CSV数据一样占用堆中的整个空间,或者占用Zip文件所需的空间?这是我们将如何从Zip到Zip进行复制的方式: byte[] buffer = new byte[8192]; while ((currentEntry =

我有一个包含大CSV的Zip。因此,它的拉链 我想在CSV中添加一列并再次压缩它


我可以将整个Zip存储在内存中,但绝对不能将整个CSV存储在内存中。因此,如果我将CSV块逐个块写入内存中ZipoutStream的特定ZipEntry。它是否会像CSV数据一样占用堆中的整个空间,或者占用Zip文件所需的空间?

这是我们将如何从Zip到Zip进行复制的方式:

        byte[] buffer = new byte[8192];
        while ((currentEntry = zipInputStream.getNextEntry()) != null) {
            ZipEntry newEntry = new ZipEntry(currentEntry.getName());
            zipOutputStream.putNextEntry(newEntry);
            int length;
            while ((length = zipInputStream.read(buffer)) > 0) {
                zipOutputStream.write(buffer, 0, length);
            }
            zipOutputStream.closeEntry();                   
        }

从这段代码中,我们可以假设程序将以8k为单位进行读/写,请尝试一下。