I can't find a solution for this anywhere! I'm creating a .docx file (a Microsoft Office XML file, which is simply a zip file with certain directories and files in it). My zip files created with Java's ZipOutputStream class are being opened just find on Mac OS X, and I tried changing the file separator to a couple different things, but Windows XP is still complaining that my generated zip file (which I'm leaving with a .zip extension for now) is invalid or corrupted and won't open it. However, Winzip will open it on Windows. That won't work for my users, though, because I need Microsoft Office 2007 to be able to automatically open these files.
Before, I was using the Apache Commons VFS, but now I've reverted to simple examples just to try to get a basic case working. Windows opens my generated zip file just fine as long as there are no subdirectories, but I must have subdirectories, and I can't find a way to get Windows Compressed Folders to play nice whenever I try to include files in subdirectories.
Here are 2 bits of sample code. The first one generates a zip file that Win XP Compressed Folders won't even open, but the second one opens even though it doesn't have the "subdirectory" zip entry in it. Does anyone know why?
Here's the one that generates a zip file that Win XP Compressed Folders can actually open:
The resulting zip file is 38 KB, but if I comment out the files String array and only insert the one file, the file size is 21 KB, so it seems like the file is being inserted, but Windows is not recognizing the one coming from the subdirectory. Any ideas?