Conceptos
GZIPInputStream es para los flujos (o archivos) ziped como gzip (".gz" extensión). No tiene ninguna información de encabezado.
GZipInputStream is for [zippeddata]
Si usted tiene un archivo zip real, usted tiene que ZipFile usuario a abrir el archivo, pedir la lista de archivos (uno en su ejemplo) y pregunte por el flujo de entrada descomprimido.
ZipFile is for a file with [header information + zippeddata]
Su método, si tiene el archivo, sería algo así como:
// ITS PSEUDOCODE!!
private InputStream extractOnlyFile(String path) {
ZipFile zf = new ZipFile(path);
Enumeration e = zf.entries();
ZipEntry entry = (ZipEntry) e.nextElement(); // your only file
return zf.getInputStream(entry);
}
Lectura de un InputStream con el contenido de un archivo .zip
Ok, si usted tiene un InputStream que puede usar (como @cletus dice) ZipInputStream. Lee una secuencia que incluye datos de encabezado.
ZipInputStream is for a stream with [header information + zippeddata]
Importante: si tiene el archivo en su PC puede utilizar ZipFile
clase para acceder a ella de forma aleatoria
Ésta es una muestra de la lectura de un archivo zip a través de un InputStream:
import java.io.FileInputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
public class Main {
public static void main(String[] args) throws Exception
{
FileInputStream fis = new FileInputStream("c:/inas400.zip");
// this is where you start, with an InputStream containing the bytes from the zip file
ZipInputStream zis = new ZipInputStream(fis);
ZipEntry entry;
// while there are entries I process them
while ((entry = zis.getNextEntry()) != null)
{
System.out.println("entry: " + entry.getName() + ", " + entry.getSize());
// consume all the data from this entry
while (zis.available() > 0)
zis.read();
// I could close the entry, but getNextEntry does it automatically
// zis.closeEntry()
}
}
}
¿Qué ya se trate? Por favor agrega un ejemplo de código. –