View Single Post
  #1 (permalink)  
Old 07-29-2007, 10:07 PM
fhucho fhucho is offline
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.
Reply With Quote
Sponsored Links