Problems creating/extracting ZIP files, anyone?

Greetings,
I am having some odd bugs with OSX in creating and extracting ZIP files.  I’m curious if anyone else has run across this or if anyone has any remedies to suggest.
The issue is that when I extract a ZIP archive, the extracted files have their creation dates and modification dates changed from the original versions.  For example, I have a directory created in 2010 and all the files were created and last modified in 2010.  However, when I ZIP the directory and re-extract it, many of the file dates change.  Some files have the creation dates changed so to match the last modified date.  In other cases, both the creation date and modification date are changed to something later than both, perhaps the date the directory was ZIPed or the date the directory was extracted.  And some files don’t seem to have the dates changed. 
I have tried various options, such as terminal, and third party programs (BetterZip, Keka, Stuffit, & Archiver to name a few) and they all seem to have some variation of this behavior.  I have tried creating the Zip with one program and extracting with the other, and still this behavior persists.  Different files seem to be affected with each combination of creating and extracting programs. 
Another odd behavior was that I tried password protecting some directories with financial data, and OSX could create the ZIP file with the password, but OSX could not unzip the file with the password it created for some files.  In every case, third party program could unzip the files with the password created in the terminal command.  This seem to happen inconsistently. 
I have tried creating a dummy account and tested it in that account, with similar results.
I’ve read the man page for the command line version of ZIP to see if there is some -option to preserve dates, but found nothing.  The typical command looks like this:
> zip -er filename.zip  sourceDir
> unzip filename.zip
File types include directories, PDFs, Text docs, Quicken files.  Ive tested other directories too with other file types.  It doesn’t seem to affect every file, but seems unpredictable.  Luckily, I still have the original uncompressed version of most directories.  But I really want to archive some directories and unarchive them when needed.  The dates matter to me because they are mostly financial files and I use the dates to know what versions were used for taxes and other things.  Also, if dates change, then backup programs start replacing the good backups with files with the corrupted dates. 
I’d appreciate any suggestions or feedback.  I there some bug in the ZIP protocol?  Is there some bug in OSX file system that is corrupting the dates with the archive and unarchive process? 
Thank you for any suggestions-
OSX 10.9.5,
MBPro 2012

OK, sorry did not read it correctly.  Read the first sentance and quit.
No, Bridge is just a browser.  You can extract more than one file at a time in Win. Explorer.  You have to do them individually, but can run multiple extractions at the same time.
There are other zip/unzip programs out there.  I know the the CS6 beta a number of users could not open it with WinZip and used alternate product just fine.

Similar Messages

  • Having problems creating a zip file with Japanese language character names

    I have a bunch of files with names in Japanese characters (also Chinese, Korean, Spanish etc, but this will do for an example). The encoding is Unicode.
    I wish to be able to put them in a zip file, then extract them again using any old zip tool (WinZip,PKZip,7-Zip etc)
    Trouble is, every time I do it, the files inside the zipfile end up with garbage character names. The contents of the files are fine, though.
    I'm aware that there used to be a bug in the java.util.zip.* classes regarding character encodings (http://bugs.sun.com/bugdatabase/view_bug.do;jsessionid=5bd4fe01ad8a7b4ec89afef5005da?bug_id=4244499) but as far as I can see it's supposed to have been fixed I have also tried the ZipOutputStream class from apache which allows you to set the encoding manually - no luck there either (just many different varieties of garbage characters)
    Test code below. What am I missing here?
    import java.io.File;
    import java.io.FileOutputStream;
    import java.io.FileReader;
    import java.io.IOException;
    public class ZipTest {
    static String uniqueFileName = "西 純.txt";
    public static void main(String[] args) {
    try {
    standardZip();
    apacheZip();
    } catch (IOException fe) {
    System.out.println("problem in file - exception " + fe.getMessage());
    public static void apacheZip() throws IOException {
    String encoding = "";
    File inputFile = new File(uniqueFileName);
    FileReader reader = new FileReader(inputFile);
    encoding = reader.getEncoding();
    System.out.println("Using Apache - Encoding = " + encoding);
    File zipFile = new File("apacheZip.zip");
    org.apache.tools.zip.ZipOutputStream zipOutputStream = new org.apache.tools.zip.ZipOutputStream(
    zipFile);
    zipOutputStream.setEncoding(encoding);
    org.apache.tools.zip.ZipEntry zipEntry = new org.apache.tools.zip.ZipEntry(uniqueFileName);
    zipEntry.setSize(inputFile.length());
    zipEntry.setTime(inputFile.lastModified());
    zipOutputStream.putNextEntry(zipEntry);
    int c = 0;
    while (c >= 0) {
    c = reader.read();
    if (c >= 0) {
    zipOutputStream.write(c);
    zipOutputStream.closeEntry();
    zipOutputStream.finish();
    public static void standardZip() throws IOException {
    String encoding = "";
    File inputFile = new File(uniqueFileName);
    FileReader reader = new FileReader(inputFile);
    encoding = reader.getEncoding();
    System.out.println("Using Java IO - Encoding = " + encoding);
    File zipFile = new File("standardZip.zip");
    FileOutputStream zipOut = new FileOutputStream(zipFile);
    java.util.zip.ZipOutputStream zipOutputStream = new java.util.zip.ZipOutputStream(zipOut);
    java.util.zip.ZipEntry zipEntry = new java.util.zip.ZipEntry(uniqueFileName);
    zipEntry.setSize(inputFile.length());
    zipEntry.setTime(inputFile.lastModified());
    zipOutputStream.putNextEntry(zipEntry);
    int c = 0;
    while (c >= 0) {
    c = reader.read();
    if (c >= 0) {
    zipOutputStream.write(c);
    zipOutputStream.closeEntry();
    zipOutputStream.finish();

    Emma_Baillie wrote:
    I have a bunch of files with names in Japanese characters (also Chinese, Korean, Spanish etc, but this will do for an example). The encoding is Unicode.
    I wish to be able to put them in a zip file, then extract them again using any old zip tool (WinZip,PKZip,7-Zip etc)
    Trouble is, every time I do it, the files inside the zipfile end up with garbage character names. The contents of the files are fine, though.This is becuase zip tool doesn't support unicode for zip entries. For example WinZip prior to 11.2 does not support Unicode characters in filenames. You need to look for the simillar information for other tools. You can find more on tools on their website.

  • Problem In Extracting xml file from Zip File

    Hi,
    In my application I am creating a zip file which contains some xml files. I am using Weblogic 8.1 for my application.
    When I try to extract the xml file from the zip file it displays error and those xml files are not extracted from the zip file.
    Otherwise on tomcat it works absolutely fine.
    Is there any support issues of using the zip files with weblogic?
    Please respond.
    Thanks in Advance.

    Friends
    I resolved the problem
    just to add the jars of
    mail.jar and activation.jar in the client side.
    regards
    ashok

  • Create Zip File In Windows and Extract Zip File In Linux

    I had created a zip file (together with directory) under Windows as follow (Code are picked from [http://www.exampledepot.com/egs/java.util.zip/CreateZip.html|http://www.exampledepot.com/egs/java.util.zip/CreateZip.html] ) :
    package sandbox;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.util.zip.ZipEntry;
    import java.util.zip.ZipOutputStream;
    * @author yan-cheng.cheok
    public class Main {
         * @param args the command line arguments
        public static void main(String[] args) {
            // These are the files to include in the ZIP file
            String[] filenames = new String[]{"MyDirectory" + File.separator + "MyFile.txt"};
            // Create a buffer for reading the files
            byte[] buf = new byte[1024];
            try {
                // Create the ZIP file
                String outFilename = "outfile.zip";
                ZipOutputStream out = new ZipOutputStream(new FileOutputStream(outFilename));
                // Compress the files
                for (int i=0; i<filenames.length; i++) {
                    FileInputStream in = new FileInputStream(filenames);
    // Add ZIP entry to output stream.
    out.putNextEntry(new ZipEntry(filenames[i]));
    // Transfer bytes from the file to the ZIP file
    int len;
    while ((len = in.read(buf)) > 0) {
    out.write(buf, 0, len);
    // Complete the entry
    out.closeEntry();
    in.close();
    // Complete the ZIP file
    out.close();
    } catch (IOException e) {
    e.printStackTrace();
    The newly created zip file can be extracted without problem under Windows, by using  [http://www.exampledepot.com/egs/java.util.zip/GetZip.html|http://www.exampledepot.com/egs/java.util.zip/GetZip.html]
    However, I realize if I extract the newly created zip file under Linux, using modified version of  [http://www.exampledepot.com/egs/java.util.zip/GetZip.html|http://www.exampledepot.com/egs/java.util.zip/GetZip.html] . The original version doesn't check for directory using zipEntry.isDirectory()).public static boolean extractZipFile(File zipFilePath, boolean overwrite) {
    InputStream inputStream = null;
    ZipInputStream zipInputStream = null;
    boolean status = true;
    try {
    inputStream = new FileInputStream(zipFilePath);
    zipInputStream = new ZipInputStream(inputStream);
    final byte[] data = new byte[1024];
    while (true) {
    ZipEntry zipEntry = null;
    FileOutputStream outputStream = null;
    try {
    zipEntry = zipInputStream.getNextEntry();
    if (zipEntry == null) break;
    final String destination = Utils.getUserDataDirectory() + zipEntry.getName();
    if (overwrite == false) {
    if (Utils.isFileOrDirectoryExist(destination)) continue;
    if (zipEntry.isDirectory())
    Utils.createCompleteDirectoryHierarchyIfDoesNotExist(destination);
    else
    final File file = new File(destination);
    // Ensure directory is there before we write the file.
    Utils.createCompleteDirectoryHierarchyIfDoesNotExist(file.getParentFile());
    int size = zipInputStream.read(data);
    if (size > 0) {
    outputStream = new FileOutputStream(destination);
    do {
    outputStream.write(data, 0, size);
    size = zipInputStream.read(data);
    } while(size >= 0);
    catch (IOException exp) {
    log.error(null, exp);
    status = false;
    break;
    finally {
    if (outputStream != null) {
    try {
    outputStream.close();
    catch (IOException exp) {
    log.error(null, exp);
    break;
    if (zipInputStream != null) {
    try {
    zipInputStream.closeEntry();
    catch (IOException exp) {
    log.error(null, exp);
    break;
    } // while(true)
    catch (IOException exp) {
    log.error(null, exp);
    status = false;
    finally {
    if (zipInputStream != null) {
    try {
    zipInputStream.close();
    } catch (IOException ex) {
    log.error(null, ex);
    if (inputStream != null) {
    try {
    inputStream.close();
    } catch (IOException ex) {
    log.error(null, ex);
    return status;
    *"MyDirectory\MyFile.txt" instead of MyFile.txt being placed under folder MyDirectory.*
    I try to solve the problem by changing the zip file creation code to
    +String[] filenames = new String[]{"MyDirectory" + "/" + "MyFile.txt"};+
    But, is this an eligible solution, by hard-coded the seperator? Will it work under Mac OS? (I do not have a Mac to try out)
    p/s To be honest, I do a cross post at  [http://stackoverflow.com/questions/2549766/create-zip-file-in-windows-and-extract-zip-file-in-linux|http://stackoverflow.com/questions/2549766/create-zip-file-in-windows-and-extract-zip-file-in-linux] Just want to get more opinion on this.
    Edited by: yccheok on Apr 26, 2010 11:41 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    Your solution lies in the File.separator constant; this constant will contain the path separator that is used by the operating system. No need to hardcode one, Java already has it.
    edit: when it comes to paths by the way, I have the bad habit of always using the front slash ( / ). This will also work under Windows and has the added benefit of not needing to be escaped.

  • Creating a zipped file from table data

    I am currently extracting data from a table and creating a flat file which is read later to create a compressed (zip) file.
    Is there a way that I can create a zipped file in one step (i.e. directly from the table data)? I am trying to reduce the number of file i/o hits in my appication.
    Thanks,
    Minesh

    Is there a way that I can create a zipped file in one step (i.e. directly from the table data)?Yes. Instead of doing something like:
    FileOutputStream fout = new FileOutputStream("flatfile");
    // write using foutdo this:
    ZipOutputStream zout = new ZipOutputStream("flatfile.zip");
    zout.putNextEntry(new ZipEntry("flatfile"));
    // write using zout

  • Create a zip files in a special way

    Dear all,
    Following my yesterday's posting, I would clarify my questions:
    I successfully created a zip file which contains a folder structure and two files from strings. See attached codes.
    However, I don't like the way that I physically created subfolder and files before add them to the zip file.
    Is there any possibility to avoid that part of creating multiple folders?
    Regards.
    Pengyou
    package com.zip.test;
    import java.io.BufferedInputStream;
    import java.io.BufferedOutputStream;
    import java.io.BufferedWriter;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.FileWriter;
    import java.io.IOException;
    import java.util.zip.ZipEntry;
    import java.util.zip.ZipOutputStream;
    public class ZipTest {
         static final int BUFFER = 2048;
         public static void main(String argv[]) {
              try {
                   BufferedInputStream origin = null;
                   FileOutputStream dest = new FileOutputStream("mytest.zip");
                   ZipOutputStream out = new ZipOutputStream(new BufferedOutputStream(
                             dest));
                   // out.setMethod(ZipOutputStream.DEFLATED);
                   byte data[] = new byte[BUFFER];
                   try {
                        String strManyDirectories = "root/dir1/dir2";
                        // Create multiple directories
                        boolean success = (new File(strManyDirectories)).mkdirs();
                        if (success) {
                             System.out.println("Directories: " + strManyDirectories
                                       + " created");
                        File outputFile = new File("root/dir1/dir2/test.html");
                        BufferedWriter bufferedWriter = new BufferedWriter(
                                  new FileWriter(outputFile));
                        bufferedWriter.write("Hello, Test");
                        bufferedWriter.close();
                        File outputFile1 = new File("root/dir1/dir2/test1.html");
                        BufferedWriter bufferedWriter1 = new BufferedWriter(
                                  new FileWriter(outputFile1));
                        bufferedWriter1.write("Hello, Test1");
                        bufferedWriter1.close();
                   } catch (IOException e) {
                   String files[] = { "root/dir1/dir2/test.html",
                             "root/dir1/dir2/test1.html" };
                   for (int i = 0; i < files.length; i++) {
                        System.out.println("Adding: " + files);
                        FileInputStream fi = new FileInputStream(files[i]);
                        origin = new BufferedInputStream(fi, BUFFER);
                        ZipEntry entry = new ZipEntry(files[i]);
                        out.putNextEntry(entry);
                        int count;
                        while ((count = origin.read(data, 0, BUFFER)) != -1) {
                             out.write(data, 0, count);
                        origin.close();
                   out.close();
              } catch (Exception e) {
                   e.printStackTrace();

    pengyou wrote:
    But I did not understand how to convert a String to ZipOutputStream with a user choosen file name and a user choosen folder structure.
    I am blocked at that point. Sorry for repeating the same question.
    That doesn't make sense to me. Even more so as your sample code suggests that you are familiar with Writer and ZipEntry concepts. Can you explain in detail where you are stuck or what part of my previous suggestion was unclear to you?
    Scratch that, I think I finally understand your problem. I think the following sample code will get you on track:import java.util.zip.ZipOutputStream;
    import java.util.zip.ZipEntry;
    import java.io.FileOutputStream;
    import java.io.BufferedWriter;
    import java.io.OutputStreamWriter;
    public class ZipTest {
        public static void main( String[] args ) throws Exception {
            final String[] content = {"bla", "blubber"};
            final String[] names = {"root/content1/c1.txt", "root/content2/c2.txt"};
            final String path = System.getProperty("user.home") + "/test.zip";
            ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(path));
            BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(zos, "UTF-8"));
            for (int i = 0; i < content.length; ++i) {
                final ZipEntry entry = new ZipEntry(names);
    zos.putNextEntry(entry);
    bw.write(content[i]);
    bw.flush();
    zos.closeEntry();
    // this will close zos, too
    bw.close();
    Edited by: thomas.behr on Apr 22, 2009 4:10 PM

  • Error while extracting zip file

    I am using the following code to extract zip files from jar file
    source = "zip/test.zip"
    destination = "c:\\"
    public void unzip(String source,String destination){
              try{
                   ZipInputStream in = new ZipInputStream( this.getClass().getResourceAsStream(source));
                   FileOutputStream fos = null;
                   ZipEntry ze = null;
                   File ff = null;
                   while ( (ze=in.getNextEntry() ) != null ){
                        System.out.println( "name=" + ze.getName() );
                        ff = new File( destination + ze.getName() );
                        if ( ze.isDirectory() ){
                             System.out.println("making "+ze.getName()+" dir ("+ ff.mkdirs() +")");
                        else{
                             fos = new FileOutputStream( ff );
                             byte[] buf = new byte[1024];
                             int len;
                             while ((len = in.read(buf)) > 0){
                                  fos.write(buf, 0, len);
                             fos.close();
                             System.out.println("wrote file "+ff.getPath()+" success=" + ff.exists() );
                   in.close();
              }catch(Exception e){
                   e.printStackTrace();
         }     But i found error in extracting zip file
    java.io.FileNotFoundException: C:\eclipse\.eclipseproduct (The system cannot find the path specified)
    I need some quick response on it.

    Nothing to do with the resource path....thats fine. Use the code below.....most likely this will fix it.......
    Added a check for directories that start with a ".".  The File utility probably thinks its a file, also added a try....check it does make the "." directories.........dont forget the dukes.
        ZipInputStream zis = null;
        FileOutputStream fos = null;
        try
          zis = new ZipInputStream( new FileInputStream( "C:\\your_path\\your_zipfile_or_jar.zip" ) );
          ZipEntry ze = null;
          File ff = null;
          while ( ( ze = zis.getNextEntry() ) != null )
            System.out.println( "name=" + ze.getName() );
            ff = new File( "C:\\your_path\\" + ze.getName() );
            if ( ze.isDirectory()  || ze.getName().startsWith("."))
              try{ System.out.println( "making " + ze.getName() + " dir (" + ff.mkdirs() + ")" ); }catch(Exception e2){}
            else
              fos = new FileOutputStream( ff );
              byte[] buf = new byte[1024];
              int len;
              while ( ( len = zis.read( buf ) ) > 0 )
                fos.write( buf, 0, len );
              fos.close();
              System.out.println( "wrote file " + ff.getPath() + " success=" + ff.exists() );
          zis.close();
        catch( Exception ex )
          ex.printStackTrace();
        finally
          try { zis.close(); }catch(Exception ex){}
          try { fos.close(); }catch(Exception ex){}
        }

  • How to create a zip file whith passwprd ?

    Hi Im trying to create a zip file using the java zip support, the zip file is being created correctly now I have one doubt I would like to know if the zip file can be protected with a password as Winzip does, if so could you tell me please how to do it.
    Regards,
    Antonio
    [email protected]

    With Core Java, for all I know you still can't.

  • Stage Area Size is 38 gb after extracting zip file of oracle R12.1.1

    Dear All,
    I need verification from you that after extracting zip file I have total size 38 gb after extracting zip file of oracle R12.1.1 for solaris 5.1 sparc 64 bit.
    I have downloaded 42 files.
    B53824-01 Part 1 of 4      29M
         B53824-01 Part 2 of 4      97M
         B53824-01 Part 3 of 4      393M
         B53824-01 Part 4 of 4      81M
         V15635-01 Part 1 of 3      1.2G
         V15635-01 Part 2 of 3      1.2G
         V15635-01 Part 3 of 3      1.1G
         V15636-01      976M
         V15637-01 Part 1 of 3      1.7G
         V15637-01 Part 2 of 3      1.7G
         V15637-01 Part 3 of 3      576M
         V15638-01 Part 1 of 3      1.6G
         V15638-01 Part 2 of 3      1.7G
         V15638-01 Part 3 of 3      557M
         V15639-01 Part 1 of 3      1.6G
         V15639-01 Part 2 of 3      1.6G
         V15639-01 Part 3 of 3      463M
         V15640-01 Part 1 of 3      1.5G
         V15640-01 Part 2 of 3      1.6G
         V15640-01 Part 3 of 3      514M
         V15641-01 Part 1 of 3      1.2G
         V15641-01 Part 2 of 3      1.6G
         V15641-01 Part 3 of 3      756M
         V15642-01      1.0G
         V15643-01 Part 1 of 7      567M
         V15643-01 Part 2 of 7      560M
         V15643-01 Part 3 of 7      593M
         V15643-01 Part 4 of 7      612M
         V15643-01 Part 5 of 7      582M
         V15643-01 Part 6 of 7      480M
         V15643-01 Part 7 of 7      551M
         V15644-01 Part 1 of 2      1.5G
         V15644-01 Part 2 of 2      1.6G
         V15645-01      1.7G
         V15646-01 Part 1 of 3      1.5G
         V15646-01 Part 2 of 3      1.2G
         V15646-01 Part 3 of 3      1.1G
         V15647-01 Part 1 of 3      1.7G
         V15647-01 Part 2 of 3      1.2G
         V15647-01 Part 3 of 3      626M
         V15648-01 Part 1 of 2      1.2G
         V15648-01 Part 2 of 2      836M
    Does these have all basice needs.
    There is also some files which I did not download may be for soa ,warehouse and library like.
    Please verify that am I going on right?
    Thanks

    I need verification from you that after extracting zip file I have total size 38 gb after extracting zip file of oracle R12.1.1 for solaris 5.1 sparc 64 bit.
    I have downloaded 42 files.
    Does these have all basice needs.You need the following files:
    From: Oracle E-Business Suite Release 12.1.1 Rapid Install Start Here (Part 1 of 4), Part Number: B53824-01 Part 1 of 4
    To: Oracle E-Business Suite Release 12.1.1 for Sun Solaris SPARC (64-bit) Rapid Install APPL_TOP - Disk 3 (Part 2 of 2), Part Number: V15648-01 Part 2 of 2
    There is also some files which I did not download may be for soa ,warehouse and library like.
    Please verify that am I going on right?You do not need to download those files.
    Thanks,
    Hussein

  • Problem with creating a ZIP file

    I have a program that uses java.util.zip to zip all the files in a user's directory (aproximately 7 files totalling 2 MB). When the files are extracted later using WinZip or a similar tool, the files appear to be the same (same file size & date), but they can not be opened by the program that uses them. When I use a binary diff tool to compare the before zip and after zip files, it shows about 20 random bytes that have changed. Anybody else seen this occur?
    Thanks

    Hi,
    I am successfull in putting all the files of a
    directory in a newly created ZIP file. But if my
    directory has a sub-directory, it's not workin....m
    not able to zip it properly. I mean, my program is
    doin it withour error but when i try to open it using
    WinZip...it's giving me an error sayin as not a proper
    archive...
    Do anyone have faced this problem??
    GauzYou need to call the following functions of ZipOutputStream after completing zipping in your code ?
         objZipOutputStream.finish();
         objZipOutputStream.close();Also for every file being zipped, you should to call
    objZipOutputStream.closeEntry()to close that zipEntry.
    Hope this helps.

  • Pdf take minutes to open inside of an extracted zip file

    I received a zip file in an email. I extracted it and there were 3 pdfs inside.  I cliked on one and the hour glass would just appear and at the top of the pdf it would say "not responding".  It finally will open but it takes minutes. Same issue for the other 2.
    What is preventing this from opening?  I have checked Control Panel and deleted all other pdf applications.  Ran Registry Cleaner and cleared Temporary internet and Windows Files from my Norton Security Suite
    I do not have any problem opening individual pdfs that I receive or create from insurance company pdf creators inside of their software.
    I am running Adobe Reader 10.1.1 on Windows Vista.  I have a friend who also seems to have the same problem who is also running Windows Vista.
    I have a new laptop running Windows 7 64 bit but there is no issue opening the pdf in that same zip file received.
    Thank you.

    Hi Michael.
    I went back to the zip folder, right cliked on it and cliked on extract all. Then tried opening each one and it just hangs.  It still hasn't opened and it is now at least 5 minutes.

  • A strange problem using the zip files

    I'm currently working on a university project with another student in which we use zip files (using the java ZipFile , and ZipOutputStream classes), we write certain data to a zip file (and verify that it is there by checking the disk). and later we read the zip file, and write it back , appending some data at the end of the file.
    although we see the changes actually take place on the disk , in one of the cases when reading the data we don't see the data we have appended before (although it is physically written on the disk).
    testing has revealed that this has something to do with the rename command or java being unsynchronized with the data actually on the disk (caching problem?).
    we use this code to preform the process:
    ZipFile zf= new ZipFile( ((Integer)lexicon.get(keyword)).intValue()+".zip");
              BufferedInputStream input= new BufferedInputStream(zf.getInputStream(new ZipEntry("data")));
              // create a temporary new zip file.
              ZipOutputStream zipst= new ZipOutputStream(new FileOutputStream( ((Integer)lexicon.get(keyword)).intValue()+".tmp.zip"));
              BufferedOutputStream output =new BufferedOutputStream(zipst);
              zipst.putNextEntry(new ZipEntry("data"));
              // stream the contents of the old file into the new file
              //(we do it this way because of the inability of the java zip file interfaces to add to an existing zip file)
              int current = input.read();
              while(current!=-1){
              output.write(current);
              current = input.read();
              output.write(entry.getBytes(false)); // add the new entrys.
              output.flush();
              zipst.closeEntry();
              output.close();
              // erase the old file.
              File toErase = new File( ((Integer)lexicon.get(keyword)).intValue()+".zip");
              toErase.delete();
              // rename the temporary file to the old files name.
              File toRename = new File( ((Integer)lexicon.get(keyword)).intValue()+".tmp.zip");
              toRename.renameTo(new File( ((Integer)lexicon.get(keyword)).intValue()+".zip"));
    we use:
    1. j2sdk 1.4.2_05
    2. running under libranet linux.
    any help will be appreciated

    the data does indeed get lost in the course fo rewriting the file, e assume this is some sort of synchronization issue with java and the file system.
    addig enteies to an existing zip file would have been great, if we had it a few weeks ago , we had to make do without this ability , and all of the code is already written and mostly working (except for the problem I mention) and we don't really want to rewrite the zip file access.
    additional testing has shown that the data gets lost when we use the rename command.
    very strange...
    thanks for the input

  • Cannot extract Zip file with Winzip after zipping with java.util.zip

    Hi all,
    I write a class for zip and unzip the text files together which can be zip and unzip successfully with Java platform. However, I cannot extract the zip file with Winzip or even WinRAR after zipping with Java platform.
    Please help to comment, thanks~
    Below is the code:
    =====================================================================
    package myapp.util;
    import java.io.* ;
    import java.util.TreeMap ;
    import java.util.zip.* ;
    import myapp.exception.UserException ;
    public class CompressionUtil {
      public CompressionUtil() {
        super() ;
      public void createZip(String zipName, String fileName)
          throws ZipException, FileNotFoundException, IOException, UserException {
        FileOutputStream fos = null ;
        BufferedOutputStream bos = null ;
        ZipOutputStream zos = null ;
        File file = null ;
        try {
          file = new File(zipName) ; //new zip file
          if (file.isDirectory()) //check if it is a directory
         throw new UserException("Invalid zip file ["+zipName+"]") ;
          if (file.exists() && !file.canWrite()) //check if it is readonly
         throw new UserException("Zip file is ReadOnly ["+zipName+"]") ;
          if (file.exists()) //overwrite the existing file
         file.delete();
          file.createNewFile();
          //instantiate the ZipOutputStream
          fos = new FileOutputStream(file) ;
          bos = new BufferedOutputStream(fos) ;
          zos = new ZipOutputStream(bos) ;
          this.writeZipFileEntry(zos, fileName); //call to write the file into the zip
          zos.finish() ;
        catch (ZipException ze) {
          throw ze ;
        catch (FileNotFoundException fnfe) {
          throw fnfe ;
        catch (IOException ioe) {
          throw ioe ;
        catch (UserException ue) {
          throw ue ;
        finally {
          //close all the stream and file
          if (fos != null)
         fos.close() ;
          if (bos != null)
         bos.close();
          if (zos != null)
         zos.close();
          if (file != null)
         file = null ;
        }//end of try-catch-finally
      private void writeZipFileEntry(ZipOutputStream zos, String fileName)
          throws ZipException, FileNotFoundException, IOException, UserException {
        BufferedInputStream bis = null ;
        File file = null ;
        ZipEntry zentry = null ;
        byte[] bArray = null ;
        try {
          file = new File(fileName) ; //instantiate the file
          if (!file.exists()) //check if the file is not exist
         throw new UserException("No such file ["+fileName+"]") ;
          if (file.isDirectory()) //check if the file is a directory
         throw new UserException("Invalid file ["+fileName+"]") ;
          //instantiate the BufferedInputStream
          bis = new BufferedInputStream(new FileInputStream(file)) ;
          //Get the content of the file and put into the byte[]
          int size = (int) file.length();
          if (size == -1)
         throw new UserException("Cannot determine the file size [" +fileName + "]");
          bArray = new byte[(int) size];
          int rb = 0;
          int chunk = 0;
          while (((int) size - rb) > 0) {
         chunk = bis.read(bArray, rb, (int) size - rb);
         if (chunk == -1)
           break;
         rb += chunk;
          }//end of while (((int)size - rb) > 0)
          //instantiate the CRC32
          CRC32 crc = new CRC32() ;
          crc.update(bArray, 0, size);
          //instantiate the ZipEntry
          zentry = new ZipEntry(fileName) ;
          zentry.setMethod(ZipEntry.STORED) ;
          zentry.setSize(size);
          zentry.setCrc(crc.getValue());
          //write all the info to the ZipOutputStream
          zos.putNextEntry(zentry);
          zos.write(bArray, 0, size);
          zos.closeEntry();
        catch (ZipException ze) {
          throw ze ;
        catch (FileNotFoundException fnfe) {
          throw fnfe ;
        catch (IOException ioe) {
          throw ioe ;
        catch (UserException ue) {
          throw ue ;
        finally {
          //close all the stream and file
          if (bis != null)
         bis.close();
          if (file != null)
         file = null ;
        }//end of try-catch-finally
    }

    Tried~
    The problem is still here~ >___<
    Anyway, thanks for information sharing~
    The message is:
    Cannot open file: it does not appear to be a valid archive.
    If you downloaded this file, try downloading the file again.
    The problem may be here:
    if (fos != null)
    fos.close() ;
    if (bos != null)
    bos.close();
    if (zos != null)
    zos.close();
    if (file != null)
    file = null ;
    The fos is closed before bos so the last buffer is not
    saved.
    zos.close() is enough.

  • Problem creating an jar file!

    Hello.
    I am trying to create an executable jar file using the following command:
    jar cmf MANIFEST.MF game.jar *.classHowever, I keep receiving the following error:
    java.io.FileNotFoundException: MANIFEST.MF (The system cannot find the file spec
    ified)
            at java.io.FileInputStream.open(Native Method)
            at java.io.FileInputStream.<init>(FileInputStream.java:64)
            at sun.tools.jar.Main.run(Main.java:124)
            at sun.tools.jar.Main.main(Main.java:904)Why am I getting this error and how can I correct this?

    Did you create a file called MANIFEST.MF? Is it in the same directory you are in now?
    And by the way, according to what I see when I run the jar command, you need to specify the jar file first, and then the manifest file:Usage: jar {ctxu}[vfm0Mi] [jar-file] [manifest-file] [-C dir] files ...
    Options:
        -c  create new archive
        -t  list table of contents for archive
        -x  extract named (or all) files from archive
        -u  update existing archive
        -v  generate verbose output on standard output
        -f  specify archive file name
        -m  include manifest information from specified manifest file
        -0  store only; use no ZIP compression
        -M  do not create a manifest file for the entries
        -i  generate index information for the specified jar files
        -C  change to the specified directory and include the following file
    If any file is a directory then it is processed recursively.
    The manifest file name and the archive file name needs to be specified
    in the same order the 'm' and 'f' flags are specified.
    Example 1: to archive two class files into an archive called classes.jar:
           jar cvf classes.jar Foo.class Bar.class
    Example 2: use an existing manifest file 'mymanifest' and archive all the
               files in the foo/ directory into 'classes.jar':
           jar cvfm classes.jar mymanifest -C foo/ .

  • Problem in deleting Zip files unzipped using java.util.zip

    I have a static methos for unzipping a zip file. after unzipping the file when i am trying to delete that file using File.delete()its not getting deleted. but when methods like exist(). canRead(), canWrite() methods are returning true what can be the possible problem ? i had closed all the streams after unzipping operation Please go through the following code.
    public static boolean unzipZipFile(String dir_name, String zipFileName) {
    try {
    ZipFile zip = new ZipFile(zipFileName);
    Enumeration entries = zip.entries();
    while (entries.hasMoreElements()) {
    ZipEntry entry = (ZipEntry) entries.nextElement();
    // got all the zip entries here
    // now has to process all the files
    // first all directories
    // then all the files
    if (entry.isDirectory()) {
    // now the directories are created
    File buf=new File(dir_name,entry.getName());
    buf.mkdirs();
    continue;
    }// now got the dirs so process the files
    entries = zip.entries();
    while(entries.hasMoreElements()) {
    // now to process the files
    ZipEntry entry = (ZipEntry) entries.nextElement();
    if (!entry.isDirectory()){
    File buf=new File(dir_name,entry.getName());
    copyInputStream(
    zip.getInputStream(entry),
    new BufferedOutputStream(
    new FileOutputStream(buf)));}
    } catch (IOException e) {
    e.printStackTrace();
    return false;
    return true;
    now i am trying to call this method to unzip a zip file
    public static void main (String arg[]){
    unzipZipFile("C:/temp","C:/tmp.zip");
    java.io.File filer = new File("C:/tmp.zip");
    System.out.println (filer.canRead());
    System.out.println (filer.canWrite());
    System.out.println (filer.delete());
    Please tell me where my program is going wrong ?

    Thanks .. the problem is solved... i was not closing the Zip file .. rather i was trying to close all the other streams that i used for IO operaion ... thanks a lot

Maybe you are looking for

  • In Sender File Adapter hw to creat a temp file in srce fldr aftr msg proces

    Hi All, I have a scenario where I am having sender File Adapter(NFS), the steps are like this 1. The input file needs to be processed and get archived with the same name in archive folder. 2. After file get processed I have to generate the blank file

  • Do I need an Aiport card to stream tunes to my stereo

    I have a 15-inch flat panel iMac that never had the wireless card. However, I am able to wirelessly compute using a USB Aeropad. My wireless router is a D-link. I have AE and only want to use it to stream my iTunes library to my stereo. I am so confu

  • ITunes wont sync my new 2nd gen iPod

    Hi, I got a new iPod but every time I try to put some music on it a window pops up and says "Attempting to copy to the disc "iPod" failed. The disc could not be read from or written to". I thought it was a problam in the iPod, but it worked on my fri

  • Issue with Plastic Screen on S10-3t

    Seen a few listings on this issue but no resolution. I brought one of the first S10-3t in the UK. One day after travelling home and the bag being on my shoulder *and could only have been lightly knocked about* i noticed a small heirline crack on the

  • Visibility Restriction in f4 help

    Hi All,           I want to restrict EAN field userwise from the standard f4 help in t-code va03. I mean when f4 is pressed there are 5 fields in standard, now i want to restrict EAN field from the f4 help userwise. If i create my own Zsearch help, h