Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-29-2007, 09:07 PM
Member
 
Join Date: Jul 2007
Posts: 2
Rep Power: 0
fhucho is on a distinguished road
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:
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.
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 07-30-2007, 03:27 AM
Senior Member
 
Join Date: Jul 2007
Posts: 135
Rep Power: 0
brianhks will become famous soon enough
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.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 07-30-2007, 05:33 PM
Member
 
Join Date: Jul 2007
Posts: 2
Rep Power: 0
fhucho is on a distinguished road
Default
Thanks, but unfortunately it didn't help...
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Moments with Windows tim Jokes and Funny Things 13 11-10-2009 01:34 PM
swt for windows Gajesh Tripathi SWT / JFace 2 10-18-2007 07:43 AM
First windows application tha_crazy New To Java 1 08-13-2007 04:22 PM
Help with windows in java lenny AWT / Swing 1 08-07-2007 07:22 AM
Help with JTextArea, resize windows paul AWT / Swing 1 07-16-2007 05:11 PM


All times are GMT +2. The time now is 07:52 AM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org