Results 1 to 3 of 3
- 07-29-2007, 08:07 PM #1
Member
- Join Date
- Jul 2007
- Posts
- 2
- Rep Power
- 0
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:
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.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();
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.
- 07-30-2007, 02:27 AM #2
Senior Member
- Join Date
- Jul 2007
- Posts
- 135
- Rep Power
- 0
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.
- 07-30-2007, 04:33 PM #3
Member
- Join Date
- Jul 2007
- Posts
- 2
- Rep Power
- 0
Similar Threads
-
Moments with Windows
By tim in forum EntertainmentReplies: 13Last Post: 11-10-2009, 12:34 PM -
swt for windows
By Gajesh Tripathi in forum SWT / JFaceReplies: 2Last Post: 10-18-2007, 06:43 AM -
First windows application
By tha_crazy in forum New To JavaReplies: 1Last Post: 08-13-2007, 03:22 PM -
Help with windows in java
By lenny in forum AWT / SwingReplies: 1Last Post: 08-07-2007, 06:22 AM -
Help with JTextArea, resize windows
By paul in forum AWT / SwingReplies: 1Last Post: 07-16-2007, 04:11 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks