From: Shawn F. <Sha...@te...> - 2002-07-12 19:55:12
|
When I use the GZIPOutputStream in the jazz.util.zip package the resulting file cannot be unzipped using gunzip. (Error msg: gunzip: test1.txt.gz: invalid compressed data--crc error) Howerver, if I use java.util.zip it works. Any ideas why? The following code works once I substituted the native class java.util.zip.GZIPOutputStream: try { // Create the GZIP output stream String outFilename = strTo; java.util.zip.GZIPOutputStream out = new java.util.zip.GZIPOutputStream(new FileOutputStream(outFilename)); // Open the input file String inFilename = strFrom; FileInputStream in = new FileInputStream(inFilename); // Transfer bytes from the input file to the GZIP output stream byte[] buf = new byte[1024]; int len; while ((len = in.read(buf)) > 0) { out.write(buf, 0, len); } in.close(); // Complete the GZIP file out.finish(); out.close(); } catch (IOException e) { System.out.println(e); } Thanks, Shawn Fuller Software Specialist E-Commerce Solutions West 9 - 3777 Kingsway, Burnaby, BC Tel 604.419.7527 |