Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

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


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

vB 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 4 05-05-2008 09:27 AM
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 +3. The time now is 11:17 PM.


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