Results 1 to 3 of 3
  1. #1
    fhucho is offline Member
    Join Date
    Jul 2007
    Posts
    2
    Rep Power
    0

    Default Zipping unpacked OpenDocument in Windows

    Hello,
    I try to pack unpacked and modified OpenDocument file (specifically .ods), using the java.util.zip package back into .ods. My code works only in Linux, not Windows.
    For zipping, I use this code:
    Java Code:
    String[] files = listOfFiles( "uncompressedOds\\"); 
    byte[] buf = new byte[1024];
    String zipFile = "table.ods";
    ZipOutputStream out = new ZipOutputStream(new FileOutputStream(zipFile));
    // compress the files
    for(int i = 0; i < files.length; i++){
        ZipEntry zipEntry = new ZipEntry(files[i]);
        out.putNextEntry(zipEntry);
        if(!new File("uncompressedOds" + File.separator + files[i]).isDirectory()){
            FileInputStream in = new FileInputStream("uncompressedOds" + File.separator + files[i]);
    	int len;
    	while((len = in.read(buf)) > 0){
    	    out.write(buf, 0, len);
    	}
    	in.close();
        }
        out.closeEntry();
    }
    out.close();
    The problem is, that the zipped ods file cannot be opened with OpenOffice - it displays a message that the file is demaged, and asks whether I want to repair it. After I select to repair the file, it opens and is entirely OK.
    In Linux the created ods file is not demaged - that's very strange.
    When I unpack the ods file (which my program created) in Windows (using gnu unzip) and pack it back using WinRar - the ods is then OK.
    In both WIn and Lin I use Java 6.

  2. #2
    brianhks is offline Senior Member
    Join Date
    Jul 2007
    Posts
    135
    Rep Power
    0

    Default

    Not sure if this will fix your problem but you may want to call flush before closing the ZipOutputStream. Some classes are picky about the need to call flush before calling close.

  3. #3
    fhucho is offline Member
    Join Date
    Jul 2007
    Posts
    2
    Rep Power
    0

Similar Threads

  1. Moments with Windows
    By tim in forum Entertainment
    Replies: 13
    Last Post: 11-10-2009, 01:34 PM
  2. swt for windows
    By Gajesh Tripathi in forum SWT / JFace
    Replies: 2
    Last Post: 10-18-2007, 07:43 AM
  3. First windows application
    By tha_crazy in forum New To Java
    Replies: 1
    Last Post: 08-13-2007, 04:22 PM
  4. Help with windows in java
    By lenny in forum AWT / Swing
    Replies: 1
    Last Post: 08-07-2007, 07:22 AM
  5. Help with JTextArea, resize windows
    By paul in forum AWT / Swing
    Replies: 1
    Last Post: 07-16-2007, 05:11 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •