FileDocCategorySizeDatePackage
SerializableZipFile.javaAPI DocExample1770Mon Feb 13 12:30:30 GMT 2006None

SerializableZipFile

public class SerializableZipFile extends Object implements Serializable

Fields Summary
private ZipFile
zf
Constructors Summary
public SerializableZipFile(String filename)

    this.zf = new ZipFile(filename);
  
public SerializableZipFile(File file)

    this.zf = new ZipFile(file);
  
Methods Summary
public voidclose()

    zf.close();
  
public java.util.Enumerationentries()

    return zf.entries();
  
public java.util.zip.ZipEntrygetEntry(java.lang.String name)

    return zf.getEntry(name);
  
public java.io.InputStreamgetInputStream(java.util.zip.ZipEntry entry)

    return zf.getInputStream(entry);
  
public java.lang.StringgetName()

    return zf.getName();
  
public static voidmain(java.lang.String[] args)


    try {
      SerializableZipFile szf = new SerializableZipFile(args[0]);
      ByteArrayOutputStream bout = new ByteArrayOutputStream();
      ObjectOutputStream oout = new ObjectOutputStream(bout);
      oout.writeObject(szf);
      oout.close();
      System.out.println("Wrote object!");

      ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
      ObjectInputStream oin = new ObjectInputStream(bin);
      Object o = oin.readObject();
      System.out.println("Read object!");
    }
    catch (Exception ex) {ex.printStackTrace();}
  
private voidreadObject(java.io.ObjectInputStream in)

  
    String filename = (String) in.readObject();
    zf = new ZipFile(filename);
  
public intsize()

    return zf.size();
  
private voidwriteObject(java.io.ObjectOutputStream out)

    out.writeObject(zf.getName());