Encontré un ejemplo del sitio de SUN (http://java.sun.com/developer/technicalArticles/Programming/compression/), pero devuelve BufferedOutputStream. Pero me gustaría obtener el archivo ZipEntry como InputStream y luego procesar el siguiente archivo. ¿Es eso posible? Mi programa no tiene acceso al disco duro, por lo que ni siquiera puede guardar archivos temporalmente.¿Cómo puedo leer archivos de un archivo Zip en la memoria con Java?
import java.io.*;
import java.util.zip.*;
public class UnZip {
final int BUFFER = 2048;
public static void main (String argv[]) {
try {
BufferedOutputStream dest = null;
FileInputStream fis = new
FileInputStream(argv[0]);
ZipInputStream zis = new
ZipInputStream(new BufferedInputStream(fis));
ZipEntry entry;
while((entry = zis.getNextEntry()) != null) {
System.out.println("Extracting: " +entry);
int count;
byte data[] = new byte[BUFFER];
// write the files to the disk
FileOutputStream fos = new
FileOutputStream(entry.getName());
dest = new
BufferedOutputStream(fos, BUFFER);
while ((count = zis.read(data, 0, BUFFER))
!= -1) {
dest.write(data, 0, count);
}
dest.flush();
dest.close();
}
zis.close();
} catch(Exception e) {
e.printStackTrace();
}
}
}
'byte [] data = new byte [BUFFER];' ?? –