Java I/O

Inflating and Deflating

import java.util.zip.*;
import java.io.*;
class ZipInputStreamExample
{
  public static void main(String argv[])
  {
    try
    {
      FileInputStream fis = new FileInputStream("test.zip");
      ZipInputStream zis = new ZipInputStream(fis);
      ZipEntry ze;
      // Get the first entry
      ze = zis.getNextEntry();
      if (ze == null)
        System.out.println("End entries");
      else
      {
        // Use it as stream or reader
        DataInputStream dis = new DataInputStream(zis);
        int i = dis.readInt();
        System.out.println("File contains " + i);
        zis.closeEntry();
      }
      zis.close();
    }
    catch(Exception e)
    {
      System.out.println(e);
    }
  }
}


José M. Vidal .

10 of 13