Very nice. Thanks for posting the code, Dave. I'll give a shot. Paul
-----Original Message----- From: David Fisher [mailto:[EMAIL PROTECTED] Sent: Wednesday, July 30, 2008 9:41 AM To: POI Users List Subject: Re: Rezip archive Hi Paul, You might find the following code fragments helpful: import java.io.*; import java.util.zip.ZipOutputStream; import java.util.zip.ZipEntry; File tmpfile = File.createTempFile("myarchive", ".zip"); FileOutputStream out = new FileOutputStream(tmpfile); ZipOutputStream zout = new ZipOutputStream(out); // writing a file from a byte stream zout.putNextEntry(new ZipEntry("ooxml.xlsx")); zout.write(<my_poi>.getBytes()); zout.closeEntry(); // writing a directory File dir = new File("/my/path/to/a/directory); pack(dir, dir.getPath(), null, zout); zout.close(); out.close(); public static void pack(File file, String root, FileFilter filter, ZipOutputStream out) throws IOException { if(file.isDirectory()){ File[] f = filter == null ? file.listFiles() : file.listFiles(filter); for (int i = 0; i < f.length; i++) { pack(f[i], root, filter, out); } } else { String path = file.getPath().substring(root.length() + 1); out.putNextEntry(new ZipEntry(path)); byte[] chunk = new byte[1024]; int len; FileInputStream is = new FileInputStream(file); while((len = is.read(chunk)) > 0) out.write(chunk, 0, len); is.close(); out.closeEntry(); } } Regards, Dave On Jul 30, 2008, at 10:10 AM, Dobson, Paul L CTR USAF AFMC 416 SCMS/ OBN wrote: > Turns out, native Windows XP zip file support doesn't work either. > Where I am, I cannot install or use any "unauthorized" software. I'm > sure there are no 3rd party zip programs that are authorized. Next > thing I'll try is writing java code to zip, unzip files. > > -----Original Message----- > From: Dobson, Paul L CTR USAF AFMC 416 SCMS/OBN > [mailto:[EMAIL PROTECTED] > Sent: Tuesday, July 29, 2008 2:57 PM > To: POI Users List > Subject: RE: Rezip archive > > I suspect you are right. I am using WinZip 8.0 (really old > version). I > am looking into just using XP native zip support. Has anyone tried > that? Does it work? > > Paul > > -----Original Message----- > From: Nick Burch [mailto:[EMAIL PROTECTED] > Sent: Tuesday, July 29, 2008 2:50 PM > To: POI Users List > Subject: Re: Rezip archive > > On Tue, 29 Jul 2008, Dobson, Paul L CTR USAF AFMC 416 SCMS/OBN wrote: >> I am trying to do some comparison to find out what it is about POI >> 3.5 > >> beta that is causing it to create invalid xlsx files. I am having a >> difficult time because when I try to zip a file after unzipping it, > the >> excel 2007 parser can no longer read it, even if I make no changes to >> the files. Any idea what I am doing wrong? > > Using a broken zip utility from the look of it. > > I've just tried using unzip v5.52 / zip v2.31 on linux. Steps were: > * mkdir expanded > * cd expanded > * unzip ../Original.xlsx > * zip -r ../Repacked.xlsx . > * scp ../Repacked.xlsx to a nearby windows box > * open Repacked.xlsx in excel 2007 without issue > > I'd try using a zip utility that does what you ask it to, without any > magic or wizardry - I suspect your gui one is doing something > unhelpful > and not telling you. > > Nick > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
