An example of unzip


EJB design: An example of unzip

  1. An example of unzip (1 messages)

    hi all, anyone has another example of unzip with source codes to demo here? This set of unzip codes don't work. Thanks!

    import java.util.*;

    public class Unzip {

      public static final void copyInputStream(InputStream in, OutputStream out)
      throws IOException
        byte[] buffer = new byte[1024];
        int len;

        while((len = >= 0)
          out.write(buffer, 0, len);


      public static final void main(String[] args) {
        Enumeration entries;
        ZipFile zipFile;

      try {
          zipFile = new ZipFile("C:\\Temp");

          entries = zipFile.entries();

          while(entries.hasMoreElements()) {
            ZipEntry entry = (ZipEntry)entries.nextElement();

            if(entry.isDirectory()) {
              // Assume directories are stored parents first then children.
              System.err.println("Extracting directory: " + entry.getName());
              // This is not robust, just for demonstration purposes.
              (new File(entry.getName())).mkdir();

            System.err.println("Extracting file: " + entry.getName());
               new BufferedOutputStream(new FileOutputStream(entry.getName())));

        } catch (IOException ioe) {
          System.err.println("Unhandled exception:");

  2. This code does not work if u use a compressed archive. If you had control on how the jar file is built, then u could make a jar without compression and this program will work just fine!