This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I'm trying to convert a log file to a gzip file, and another application will unzip the file to a log file. I have attached my class that does so below. This is the error I get :
------------------------------ 1132 [Thread-0] INFO util.GZipUtil - in unzip func 1132 [Thread-0] INFO util.GZipUtil - input file name = 1098035357042.gzip 1132 [Thread-0] INFO util.GZipUtil - output file name = c:\aaa\logs\1098035357042.log 1162 [Thread-0] INFO util.GZipUtil - (int)file.length() = 105 java.io.IOException: Corrupt GZIP trailer 1162 [Thread-0] DEBUG util.GZipUtil - java.io.IOException: Corrupt GZIP trailer 1162 [Thread-0] INFO LoggingTask - unzippedFile - c:\aaa\logs\1098035357042.log at java.util.zip.GZIPInputStream.readTrailer(Unknown Source) at java.util.zip.GZIPInputStream.read(Unknown Source) at java.io.FilterInputStream.read(Unknown Source) at com.patronsolutions.messaging.util.GZipUtil.unzip(GZipUtil.java:108) at LoggingTask.run(LogGateLinkInfo.java:131) at java.util.TimerThread.mainLoop(Unknown Source) at java.util.TimerThread.run(Unknown Source) V10/1/20042:32:23 PMPARKGATE A110180060033846ERUD CODE-10110331221True
I did find a bug that says that the gzip has a bug if the inflated file size is >2GB then we get the above exception. In my case I get it even when the file size is 89 bytes. Also my data get altered after I have unzipped it. Data before zipping: V10/1/20042:32:23 PMPARKGATE A110180060033846BUD CODE-11110031221True
Data after unzipping: V10/1/20042:32:23 PMPARKGATE A110180060033846ERUD CODE-10110331221True
Can anyone help me out with this? Should I use gzip or zip for this? How does one decide which one to use? I read that the zip(not gzip) also has a bug in java. What does this "Corrupt GZIP trailer" mean?