GZip / GZIPOutputStream problem.

Hi guys.
This is my problem:
I'm getting some information from database, formatting it to a String and sending back to the DB for future use.
Is there any way to GZip it, store GZipped info in the DB, and when sending to client use GZIPOutputStream ?
Now I save it as a String, and use this code for outputting:
GZIPOutputStream gzos = new GZIPOutputStream(response.getOutputStream());
response.setHeader("Content-Encoding", "gzip");
gzos.write(sdl.outPut.toString().getBytes());
gzos.close();
Any help will be appriciated,
Thanks in advance, Vadim.

Thanks.
But how?
What should I use for OutputStream?
When I do gzos.write() it sends it to the response, so I should change this line: GZIPOutputStream(response.getOutputStream()) for something else...
Any ideas?

Similar Messages

  • GZipOutputStream problem!

    Hello,
    I am running into a weird problem which is intermittent.
    I am trying to generate an encrypted URL from an input string.
    I am using URLEncoding, MD5Checksum, zipping (for compression) and using BlowFish for encryption. The input string is a variable length string though in this case, the problem is showing up in a string of fixed length.
    The compression method uses GZipOutputStream with ByteArrayOutPutStream as the underlying stream to compress data.
    This compressed data is then used as the input to BlowFish for getting the encrypted result which is then Base64 and URL encoded.
    The problem is that if the encryption program is called in a loop with the same payload string as input, the encryption program sometimes generates an invalid URL. Following is the zip utility.
    private static byte[] zipIt ( String parameterString )
            byte[] zipped;
            try {
                ByteArrayOutputStream catcher = new ByteArrayOutputStream();
                GZIPOutputStream gzipOut = new GZIPOutputStream( catcher );
                byte[] bytesToZip = parameterString.getBytes();
                gzipOut.write( bytesToZip, 0, bytesToZip.length );
                gzipOut.close();
                return catcher.toByteArray();
            catch ( Exception ioe ) {
                ioe.printStackTrace();
                return "error".getBytes();
        }The length of the compressed string generated by this method is different (for the most part it is the same) on certain iterations.
    Is there an issue with the GZipOutputStream or the ByteArrayOutputStream? By the way, I tried this using both JDK 1.3.3 and 1.5.03.
    Thanks in advance,
    coderiyer

    Thanks for the response. For Base64, an open source class is being used. This http://iharder.sourceforge.net/current/java/base64/ is the link to this class. Version 1.3.6 is being used. What I don't understand is even if I don't remove the URLDecode on the decryption side after removing URLencode on the encryption end, it still works. Following is the legacy code for encryption/decryption. By the way, to answer your earlier question, the client is having problems in using the encrypted URL when it gets decrypted but it has been found that the encryption was incorrect in the first place.
    Thanks for your help again.
    coderiyer
    public static String encryptPayload (String payload, String authKey) {
    try {
    // Steps for creating an encrypted URL:
    // 1 - Calculate the checksum
    // 2 - Concatenate the checksum and payload
    // 3 - URL Encode
    // 4 - Compress the string using zipIt (GZIP)
    // 5 - Encrypt using Blowfish and SunJCE
    // 6 - Base 64 encode
    // 7 - URL encode
    // 8 - Return the complete string
    BlowFishUtil bfUtil = new BlowFishUtil();
    logger.debug("---------------------------------------");
    logger.debug("encryptPayload payload");
    logger.debug(payload);
    logger.debug("authKey");
    logger.debug(authKey);
    logger.debug("---------------------------------------");
    String sCheckSum = getMD5Checksum(payload);
    String encodeBuffer = sCheckSum + payload;
    logger.debug("---------------------------------------");
    logger.debug("sCheckSum");
    logger.debug(sCheckSum);
    logger.debug("---------------------------------------");
    encodeBuffer = URLEncoder.encode(encodeBuffer);
    logger.debug("---------------------------------------");
    logger.debug("URLEncoder.encode");
    logger.debug(encodeBuffer);
    logger.debug("---------------------------------------");
    byte[] aryEncodeBuf = zipIt(encodeBuffer);
    logger.debug("---------------------------------------");
    logger.debug("zipIt");
    logger.debug(new String(aryEncodeBuf));
    logger.debug("---------------------------------------");
    aryEncodeBuf = bfUtil.encryptSecretKey(authKey.getBytes(),aryEncodeBuf);
    logger.debug("---------------------------------------");
    logger.debug("encryptSecretKey");
    logger.debug(new String(aryEncodeBuf));
    logger.debug("---------------------------------------");
    encodeBuffer = Base64.encodeBytes(aryEncodeBuf);
    logger.debug("---------------------------------------");
    logger.debug("Base64.encodeBytes");
    logger.debug(encodeBuffer);
    logger.debug("---------------------------------------");
    encodeBuffer = URLEncoder.encode(encodeBuffer);
    logger.debug("---------------------------------------");
    logger.debug("URLEncoder.encode");
    logger.debug(encodeBuffer);
    logger.debug("---------------------------------------");
    return encodeBuffer;
    catch (Exception e) {
    logger.debug("[PDFWebApiDelegate:encryptPayload] - Exception : " + e );
    return null;
    public static String decryptPayload (String payload, String authKey) {
    try {
    // Steps for decrypted a URL:
    // 1 - URL decode
    // 2 - Base 64 encode
    // 3 - Decrypt using Blowfish and SunJCE
    // 4 - Decompress the string using unzipIt (GZIP)
    // 5 - Strip off the checksum, calculate the checksum from the payload
    // and verify they match
    // 6 - Return the decrypted payload
    String decodeBuffer = "";
    BlowFishUtil bfUtil = new BlowFishUtil();
    logger.debug("---------------------------------------");
    logger.debug("decryptPayload payload");
    logger.debug(payload);
    logger.debug("authKey");
    logger.debug(authKey);
    logger.debug("---------------------------------------");
    decodeBuffer = URLDecoder.decode(payload);
    logger.debug("---------------------------------------");
    logger.debug("URLDecoder.decode");
    logger.debug(decodeBuffer);
    logger.debug("---------------------------------------");
    decodeBuffer = Base64.decodeToString(decodeBuffer);
    logger.debug("---------------------------------------");
    logger.debug("Base64.decodeToString");
    logger.debug(decodeBuffer);
    logger.debug("---------------------------------------");
    byte[] aryDecodeBuf = bfUtil.decryptSecretKey(authKey.getBytes(), decodeBuffer.getBytes());
    logger.debug("---------------------------------------");
    logger.debug("decryptSecretKey");
    logger.debug(new String(aryDecodeBuf));
    logger.debug("---------------------------------------");
    aryDecodeBuf = unzipIt(aryDecodeBuf);
    logger.debug("---------------------------------------");
    logger.debug("unzipIt");
    logger.debug(new String(aryDecodeBuf));
    logger.debug("---------------------------------------");
    String sBuf = new String(aryDecodeBuf);
    logger.debug("---------------------------------------");
    logger.debug("new String(aryDecodeBuf)");
    logger.debug(sBuf);
    logger.debug("---------------------------------------");
    sBuf = URLDecoder.decode(sBuf);
    logger.debug("---------------------------------------");
    logger.debug("URLDecoder.decode");
    logger.debug(sBuf);
    logger.debug("---------------------------------------");
    int iPos = sBuf.indexOf("st=");
    logger.debug("---------------------------------------");
    logger.debug("iPos of st=");
    logger.debug(String.valueOf(iPos));
    logger.debug("---------------------------------------");
    if (iPos>=0) {
    String sURLCheckSum = sBuf.substring(0,iPos);
    sBuf = sBuf.substring(iPos,sBuf.length());
    String sCheckSum = getMD5Checksum(sBuf);
    if (!sCheckSum.equals(sURLCheckSum)) {
    logger.debug("[PDFWebApiDelegate:decryptPayload] ERROR: Checksums do not match.");
    logger.debug("---------------------------------------");
    logger.debug("urlchecksum");
    logger.debug(sURLCheckSum);
    logger.debug("calcedchecksum");
    logger.debug(sCheckSum);
    logger.debug("sBuf");
    logger.debug(sBuf);
    logger.debug("---------------------------------------");
    return new String(sBuf);
    catch (Exception e) {
    logger.debug("[PDFWebApiDelegate:decryptPayload] - Exception : " + e );
    return null;
    * Creates an MD5 checksum for the passed <code>String</code>
    * @param mess The message for which we are determining the check sum.
    * @return String The checksum string
    private static String getMD5Checksum( String mess ){
    String hexHashCode = "";
    String hashCode = "";
    try {
    MessageDigest md = MessageDigest.getInstance("MD5");
    byte[] message = mess.getBytes("UTF-8");
    md.update( message );
    byte[] hash = md.digest();
    for ( int i=0; i < hash.length; i++ ){
    int x = hash[i] & 0xFF;
    if (x < 0x10) {
    hexHashCode += "0";
    hexHashCode += (Integer.toHexString(x));
    hashCode += hash[i]+" _ ";
    catch (Exception e) {
    e.printStackTrace();
    return "error";
    return hexHashCode;
    private static byte[] zipIt ( String parameterString )
    byte[] zipped;
    try {
    ByteArrayOutputStream catcher = new ByteArrayOutputStream();
    GZIPOutputStream gzipOut = new GZIPOutputStream( catcher );
    byte[] bytesToZip = parameterString.getBytes();
    gzipOut.write( bytesToZip, 0, bytesToZip.length );
    gzipOut.close();
    return catcher.toByteArray();
    catch ( Exception ioe ) {
    ioe.printStackTrace();
    return "error".getBytes();
    private static byte[] unzipIt ( byte[] buffer ) {
    ByteArrayOutputStream outBuffer = new ByteArrayOutputStream();
    ByteArrayInputStream inBuffer = new ByteArrayInputStream(buffer);
    try {
    GZIPInputStream gzip = new GZIPInputStream(inBuffer);
    byte[] tmpBuffer = new byte[256];
    int n;
    while ((n = gzip.read(tmpBuffer)) >= 0) {
    outBuffer.write(tmpBuffer, 0, n);
    return outBuffer.toByteArray();
    catch (Exception e) {
    logger.debug("[PDFWebApiDelegate:unzipIt] - Exception : "+e);
    return null;
    }

  • GZip Version Problems

    Hello Everyone,
    I have the need to decompress an array of bytes that are given to me in gzip format. The problem that I am facing is that I beleive that the version of gzip that the bytes are compressed with, is different than the version of gzip that is built into the java API. Every time I try to unzip the bytes using GZIPInputStream, I get the error "Not in gzip format." Is there any way I can decompress gzip files compressed with an older version of gzip? Does anyone know the version of Gzip java uses?
    Thanks for all the help
    - Jon
    Here is my decompress code:
    static byte[] Decompress(byte[] buffer) throws IOException
              ByteArrayInputStream bin = new ByteArrayInputStream(buffer);
              GZIPInputStream zip = null;
              try
                   zip = new GZIPInputStream(bin);
                   ByteArrayOutputStream bout = new ByteArrayOutputStream();
                   while(true)
                        int b = zip.read();
                        if(b == -1)
                             break;
                        bout.write(b);
                   return bout.toByteArray();
              finally
                   if (zip != null)
                        zip.close();
         }

    Jpmon1 wrote:
    It is a gzip file, we use a C++ gzip library to compress it. The version of the gzip library in C++ is 1.1. We can decompress it fine through the C++ library.Can't really diagnose the problem if you can't post standalone code. Put your gzip file into a hard-coded byte[] and post that and code that demonstrates the problem.
    EDIT: Also, are you aware there is a difference between gzip the file format, and the underlying compression mechanism (DEFLATE)?
    Edited by: paul.miner on Jan 30, 2008 10:26 AM

  • Not in GZIP format problem

    I am experiencing the following IOException when using the GZIPInputStream:
        java.io.IOException: Not in GZIP format
            at java.util.zip.GZIPInputStream.readHeader(GZIPInputStream.java:131)
            at java.util.zip.GZIPInputStream.<init>(GZIPInputStream.java:58)
            at java.util.zip.GZIPInputStream.<init>(GZIPInputStream.java:68)
            ...I am trying to read an Entity Body from an HTTP response that has been compressed using GZIP compression. I read in chunks of 4K bytes, but my first read always ends at the Entity Body (this is not a problem of course, but I thought it was a bit odd). However, this my first read of an InputStream always gives me the following:
    Status-Line
    Headers
    CRLF
    So, the next read would return me the first byte of the Entity Body. By investigating the supplied Headers I discovered that GZIP compression is used. Therefore, I create a GZIPInputStream with the original InputStream as parameter. But when I start reading from the GZIPInputStream I get the mentioned exception.
    Looking into the GZIPInputStream it seems to have a problem with the GZIP header magic number (0x8b1f). This magic number consists of two bytes. I thought it would be nice to try the following, just to see what happend:
        byte[] gzipHeader = new byte[2];
        inputStream.read(gzipHeader, 0, gzipHeader.length);
        GZIPInputStream gzipInputStream =
            new GZIPInputStream(
                new SequenceInputStream(
                    new ByteArrayInputStream(gzipHeader), inputStream));
        ...And guess what? This seems to solve my problem, however I would not consider this to be a nice fix. Looking to see what is in the byte array, I discovered the following: 0x1f8b. I found the following snippet of code in GZIPInputStream:
        private int readUShort(InputStream in) throws IOException {
            int b = readUByte(in);
            return ((int)readUByte(in) << 8) | b;
        }This method is used to read in the GZIP header magic number. Now correct me if I'm wrong, but reading the bytes 0x1f8b results in the desired 0x8b1f. Therefore my little test mentioned earlier works, but why doesn't the following work:
        GZipInputStream gzipInputStream = new GZIPInputStream(inputStream);
        ....Can anybody help me with this?
    Jack...

    http://en.wikipedia.org/wiki/Gzip
    Other uses
    The �Content-Encoding� header in HTTP/1.1 allows clients to optionally receive compressed HTTP responses and (less commonly) to send compressed requests. The standard itself specifies two compression methods: �gzip� (RFC 1952; the content wrapped in a gzip stream) and �deflate� (RFC 1950; the content wrapped in a zlib-formatted stream). Compressed responses are supported by many HTTP client libraries, almost all modern browsers and both of the major HTTP server platforms, Apache and Microsoft IIS. Many server implementations, however, incorrectly implement the protocol by using the raw DEFLATE stream format (RFC 1951) instead. The bug is sufficiently pervasive that most modern browsers will accept both RFC 1951 and RFC 1950-formatted data for the �deflate� compressed method.

  • GZip uncompression problem

    Hi,
    I use java.util.zip package to compress and uncompress the gzip files. Code works fine but I have a problem as follows;
    I get a tar file with tftp from the ASAM and in this tar file there exists a gzip file. My program is not able to uncompress this file. However, I am able to decompress this file with GNU zip (gunzip filename) and compress it again (gzip filename). The last file that I compressed can be handled by my program.
    The interesting thing is the size of the file decreases when I compress it with GNU zip. I have no idea about the compression used at the ASAM side but it is declared as GNU zip.
    Is there anyone have any idea about the problem?
    Thanks

    Have you tried GZIPInputStream? If so, I think Apache or maybe Gnu have a zip file class set that should have no problem opening the file. I ran into the same problem at one time. I didn't have time to follow up because I switched groups at work.

  • Java.io.IOException: Corrupt GZIP trailer

    I have some code to gunzip a byte array of data. I've used this code frequently and it works well. However, I just tried unzipping a byte[] array that is 4,529,218 bytes which expands to a file that is 2,157,763,194 bytes (on an SGI).
    I get a:
    java.io.IOException: Corrupt GZIP trailer
    thrown from the while ( ( length = zipin.read(buffer, 0, sChunk) ) != -1) line below.
    I did a quick Google search and found these links:
    http://www.aoindustries.com/docs/aocode-public/com/aoindustries/util/zip/CorrectedGZIPInputStream.html
    http://www.sanger.ac.uk/Software/Artemis/artemis_docs/uk.ac.sanger.pathogens.WorkingGZIPInputStream.html
    with comments like:
    Works around the "Corrupt GZIP trailer" problem in GZIPInputStream by catching and ignoring this exception.
    A wrapper class to work around a bug in GZIPInputStream. The read() method sometimes throws a IOException complaining about a Corrupt GZIP trailer on the jdk 1.1.8-13 on the Alphas. This wrapper catches and ignores that exception.
    The code below writes out the correct number of bytes to the filesystem, but I get the IOException. From my Google search, it appears that some people have run into this problem before. Does anyone here know if this is a bogus error, or if it is valid? Is this a known "bug" in Java?
    Note: the file size is larger than the Integer.MAX_SIZE. Is there an integer somewhere in the code that checks the trailer that was exceeded because of the file size?
    (I ommited some catch code to make reading it easier)
    private void gunzip(byte[] data, File file)
        int sChunk = 8192;
        // create input stream
        GZIPInputStream zipin;
        try
            ByteArrayInputStream in = new ByteArrayInputStream(data);
            zipin = new GZIPInputStream(in);
        catch (IOException e)
            // omitted for clarity
        byte[] buffer = new byte[sChunk];
        FileOutputStream out = null;
        // decompress the data
        try
            out = new FileOutputStream(file);
            while ( ( length = zipin.read(buffer, 0, sChunk) ) != -1) // error here
                out.write(buffer, 0, length);
        catch (IOException e)
            // omitted for clarity
        finally
            try
                out.close();
                zipin.close();
            catch(IOException e)
                // omitted for clarity
    }

    In GZIPInputStream.java:
         * Reads GZIP member trailer.
        private void readTrailer() throws IOException {
         InputStream in = this.in;
         int n = inf.getRemaining();
         if (n > 0) {
             in = new SequenceInputStream(
                   new ByteArrayInputStream(buf, len - n, n), in);
         long v = crc.getValue();
         if (readUInt(in) != v || readUInt(in) != inf.getTotalOut()) {
             throw new IOException("Corrupt GZIP trailer");
        }This line
    if (readUInt(in) != v || readUInt(in) != inf.getTotalOut())appears to be verifying the CRC value and data size from the trailer with data actually read from the stream.
    The inf.getTotalOut() returns an integer. My file size is greater than a 32 bit integer value.
    I looked at the GZip file specification at:
    http://www.faqs.org/rfcs/rfc1952.html
    and see that the trailer input size is defined as:
    ISIZE (Input SIZE)
                This contains the size of the original (uncompressed) input
                data modulo 2^32.I assume data modulo 2^32 means that this is supposed to be a 32 bit integer.

  • Poor I/O Performance on Solaris - v1.4.1_01

    Does anyone have any comments on the following?
    It's an I/O analysis done to determine which Java
    methods might be used to replace an existing C++
    platform-specific file re-compression subsystem.
    The system has to handle up to 200,000 files per
    day (every day).
    Java IO test results for converting ZERO_ONE compressed
    files to standard compressed files.
    Java 1.4.1, 12-04-2002
    The input dataset contains 623,230,991 bytes in 1391 files.
    The input files are in ZERO_ONE compression format.
    For all tests:
    1) an input data file was opened in buffered mode.
    2) the data was read from the input and expanded
    (byte by byte).
    3) the expanded data was written to a compressing
    output stream as it was created.
    4) repeat 1 thru 3 for each file.
    64K buffers were used for all input and output streams.
    Note: Items marked with "**" hang at random on Solaris
    (2.7 & 2.8) when processing a large number of small files. They always hang on BufferedInputStream.read().
    There may be a deadlock situation with the 'process
    reaper' because we're calling 'exec()' and 'waitFor()'
    so quickly. The elapsed times for those items are
    estimates based on the volume of data processed up to
    the point where the process hung. This 'bug' has been
    reported to Sun.
    -- elapsed time --
    NT Solaris 2.7 Method
    n/a 18 min Current C++ code:
    fopen(r) -> system(compress)
    19 min 19 min ** BufferedInputStream -> exec(compress)
    29 min 21 min 1) BufferdInputStream -> file
    2) exec(compress file)
    24 min 42 min ** BufferedInputStream -> exec(gzip)
    77 min 136 min BufferedInputStream -> GZIPOutputStream
    77 min -- BufferedInputStream -> ZipOutputStream
    The performance of GZIPOutputStream and ZipOutputStream
    makes them useless for any Production system. The 2x
    performance degradation on Solaris (vs NT) for these two
    streams is surprising. Does this imply that the 'libz'
    on Solaris is flawed? Notice that whenever 'libz' is
    involved in the process stream (exec(gzip),
    GZIPOutputStream, ZipOutputStream) the elapsed time
    climbs dramatically on Solaris.

    Re-submitted Performance Matrix with formatting retained.
    Note: for the "-> system()" and "-> exec()" methods, we write to the
    STDIN of the spawned process.
    -- elapsed time --
    NT     Solaris 2.7 Method
    n/a    18 min      Current Solaris C++ code:
                         fopen(r) -> system("compress -c >aFile")
    19 min 19 min **   BufferedInputStream -> exec("compress -c >aFile")
    29 min 21 min      1) BufferdInputStream -> "aFile"
                       2) exec("compress aFile")
    24 min 42 min **   BufferedInputStream -> exec("gzip -c aFile")
    77 min 136 min     BufferedInputStream -> GZIPOutputStream("aFile")
    77 min --          BufferedInputStream -> ZipOutputStream("aFile")

  • Problem with Compression (Deflater & GZip)

    Hi All,
    I've large data as a String which I need to save in Oracle in VARCHAR2 column. As Varchar2 allows maximum of 4000 characters, I wish to compress this String and save in DB.
    I tried to compress the String using Delfater and GZip. In both methods I uses Streams concep (DeflaterOutputStream, GZipOutputStream) and both Classes have the option to return the Compressed data in byte[] and String format.
    When I returned in String format, the same String is giving error while decompressing "java.util.zip.ZipException: incorrect data check". How to solve this problem.
    When I tried to save the compressed String in DB (Oracle),
    initially I got the error "java.sql.SQLException: Malformed SQL92 string at position: 1109"
    and later I tried to save like this 'strCompressed.replace("'","''") i.e., I replaced all single quotes to 2-single quotes and the error message is "java.sql.SQLException: ORA-00911: invalid character".
    Is there any character to replace in the compressed String. and how to solve the problem with decompression.
    Please help me in this.
    Thanks in advance.
    Regards
    Pavan Pinnu.

    both Classes have the option to return the Compressed data in byte[] and String format.Don't do that. String is not a container for binary data. You can't use it for compressed data. Use the byte[], send the byte[] to the database, get it back from the database, uncompress it, and then turn that back into a String.

  • Socket + GZip Stream + Object Stream problem

    Hello,
    I've been having a problem with my threaded networked application. I want to send GZipped Objects over a socket, but the ObjectInputStream constructor blocks. I understand that it is waiting for header information from the corresponding ObjectOutputStream. I am sure that the socket connection has been established, and the ObjectOutputStream is constructed before the ObjectInputStream on the other end. The header information never seems to get to the other end.
    If I remove the Gzip filter stream, everything works great. I'm thinking that the Gzip stream is buffering the 4 bytes of header info, waiting for more data before actually compressing anything. I've tried flushing everything, to no help. I've tried finish()ing the Gzip stream, but that means I can't send my object payload. I've checked the buffers of all the stream objects and see the Object Stream's header in its buffer, but never seems to get into the GZIPOutputStream's buffer.
    Has anyone successfully used Object Stream > GZIP Stream > Socket Stream before?
    I'm not interested in examples that use file streams, since I get the impression that Gzip works fine with those (and maybe even designed only for those, not for sockets).
    Thanks for any help.
    Dave C

    Thanks. I see what I'm doing differently now. I was trying to send multiple objects over the gzip stream, not 1 at a time, finish(), and construct a new Gzip and Object output stream.
    Seems to work with a ByteArrayOutput/InputStream, now to try with a socket..

  • What is difference between C# Gzip and Java swing GZIPOutputStream?

    Hi All,
    I have a Java swing tool where i can compress file inputs and we have C# tool.
    I am using GZIPOutputStream to compress the stream .
    I found the difference between C# and Java Gzip compression while a compressing a file (temp.gif ) -
    After Compression of temp.gif file in C# - compressed file size increased
    while in java i found a 2% percentage of compression of data.
    Could you please tell me , can i achieve same output in Java as compared to C# using GZIPOutputStream ?
    Thank a lot in advance.

    797957 wrote:
    Does java provides a better compression than C#?no idea, i don't do c# programming. and, your question is most likely really: "does java default to a higher compression level than c#".
    Btw what is faster compression vs. better compression?meaning, does the code spend more time/effort trying to compress the data (slower but better compression) or less time/effort trying to compress the data (faster but worse compression). most compression algorithms allow you to control this tradeoff depending on whether you care more about cpu time or disk/memory space.

  • Gzip problem on download files

    I've downloaded the files for Oracle 9i Database from http://otn.oracle.com/software/products/oracle9i/htdocs/linuxsoft.html
    When I try to gunzip the files, I get an error message
    gunzip: Linux9i_Disk1.cpio.gz: not in gzip format
    The files I have are Linux9i_Disk1.cpio.gz, Linux9i_Disk2.cpio.gz, and Linux9i_Disk3.cpio.gz for version 9.01 for Linux. I've used both Mozilla and Netscape to download the files. Any suggestions?
    Thanks,
    --Carl                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    I had the same problem. What I found was this: I downloaded the files to a NT machine first and then copied them to my linux box.
    Unknown to me, Windows automatically unzips the files. When I executed the cpio command and included the .gz extension, the Disk1, Disk2, Disk3 directories were created successfully.
    hope it helps,

  • Problem in flushing an Object - ObjectOutputzStream on GZipOutputStream

    Hi
    I have the following code, which is meant for writting a serialized java objects into a file.
    FileOutputStream outFile = new FileOutputStream(fileName);
    GZIPOutputStream gzipOut = new GZIPOutputStream(outFile);
    ObjectOutputStream out = new ObjectOutputStream(gzipOut);The following two lines will be called multiple times (i.e. whenever I receive java object for writing)
    out.writeObject(msg); //msg is a serialized java object
    out.flush();
    Here I'm not seeing the object written into the file when I call flush.
    Only when I close the ObjectOutputStream the objects are getting written to the file.
    Can anybody give me a solution how to write each object lively to the file whenever I receive it.
    Thanks,
    Bhaskar

    You will need to do an out.reset() before your out.write() because and ObjectOutputStream will cache the array list referenced by 'a' the first time it is written and then just write a reference to it after that. The reset() clears the cache.
    Note - you might also want to do a clear() on the array list before adding the two values as it will get bigger and bigger and bigger.
    Message was edited by:
    sabre150

  • Problem with gzip

    hi friends
    i want to upload a gzipfile to httpserver there unzip it.with normal data i was successful but when i sending txt file with this data :
    <ipaddress ip="127.0.0.1">
    <priority>9</priority>
    <timestamp>Feb 6 18:45:3</timestamp>
    <processname>service control manager</processname>
    <processid>7035</processid>
    <typeofmsg>info</typeofmsg>
    <actualmsg> CSE-7SDT2TRHU2F\Administrator The NTsyslog service was successfully sent a start control. </actualmsg>
    <hostname>null</hostname>
    </ipaddress>
    at server when i unzip the file i was having fallowing exception :
    java.io.IOException: Corrupt GZIP trailer
    at java.util.zip.GZIPInputStream.readTrailer(GZIPInputStream.java:174)
    at java.util.zip.GZIPInputStream.read(GZIPInputStream.java:89)
    at java.io.FilterInputStream.read(FilterInputStream.java:90)
    at UnZip.decompress(MainServer.java:143)
    at MainServer.main(MainServer.java:220)
    plz any try to help me

    Maybe you didn't flush or close the stream, so you
    lost the last chunk of it?Most probably. flush() on the GZIP stream ain't enough. It has to call finish(), too. It's impli.. implicit... automatically done when you close it, but it won't work otherwise.

  • GZip problem (once again)

    Hi,
    I have a byte[] containing data compressed in GZip. I'm using the inflater for decompression but i receive this error:
    java.util.zip.DataFormatException: unknown compression methodAnother, rather stupid, question i have is - does the GZipInputStream reads and decompresses the data or does it leave it as is?
    Thanks,
    Snayit

    java.util.zip.DataFormatException: unknown
    compression methodSome code?
    Another, rather stupid, question i have is - does the
    GZipInputStream reads and decompresses the
    data or does it leave it as is?I am guessing you mean "does it alter the orginal file", no. Infact it does not even know if it is a file. The Stream could come from anything (HTTP server for example).

  • GZip error in Solaris 9

    I have wrote a program using GZIP to compress data, it work well in Solaris 2.6 with any any version of JDK. But recently we plan to migrate the OS to Solaris 9, and I found the program nolonger work now, it throws out a
    java.io.Exception : not a GZIP format
    My new Environment is Solaris 9 with JDK1.4.2 (32-bits). Does anyone come across this problem?
    My Testing Program
    import java.util.zip.GZIPOutputStream;
    import java.util.zip.GZIPInputStream;
    import java.io.*;
    public class testzip {
    public static void main(String argv[]) {
    String strCompressed = compress("<xml><test>ABCD1234</test></xml>") ;
    System.out.println ("===========================================") ;
    System.out.println (strCompressed) ;
    System.out.println ("===========================================") ;
    System.out.println (decompress(strCompressed)) ;
    System.out.println ("===========================================") ;
    public static String compress(String s) {
    String ret=null;
    try {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    GZIPOutputStream gz = new GZIPOutputStream(baos);
    gz.write(s.getBytes("UTF8"));
    gz.close();
    baos.close();
    ret=baos.toString();
    } catch(Exception e) {
    e.printStackTrace();
    return ret;
    public static String decompress(String s) {
    String obj=null;
    try {
    ByteArrayInputStream bais = new ByteArrayInputStream(s.getBytes());
    GZIPInputStream gz = new GZIPInputStream(bais);
    BufferedInputStream bis = new BufferedInputStream(gz);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    byte[] data = new byte[1];
    int count;
    while ((count=bis.read(data))!=-1) {
    baos.write(data);
    obj =new String(baos.toByteArray());
    gz.close();
    bais.close();
    } catch(Exception e) {
    e.printStackTrace();
    return obj;
    Thanks
    Kin

    Here is the code where I am calling the html cleaner method. This works fine in a Windows env but fails in Solaris. If I comment out the call to removeHtml(value).trim it will work. It will even work if I make a different call removeHtml("string to strip") from the main method. Why would it work in one place but not the other in Solaris, and why would it always work in Windows? Does anybody have any ideas?
               while (rs.next ()) {
                    for (int i = 1; i <= columnCount; ++i) {
                        String value = rs.getString (i);
                        if (rs.wasNull ()){
                            value = "<null>";
                        String columnName = rsmd.getColumnName(i).trim();
                        if(clean&&(columnName.equalsIgnoreCase("DESC")
                                  ||columnName.equalsIgnoreCase("HEADER")
                                  ||columnName.equalsIgnoreCase("TEXT")))
                             //Clean the text
                             //value = removeHtml(value).trim(); //remove html markup
                             value = value.replace('\n', ','); //remove new lines
                             value = value.replace('\r', ','); //remove carriage returns
                             value = replaceString(value, "&mdash", "-"); //remove dash markup
                           outputBuffer.append (value.trim());                      
                        outputBuffer.append ("||");
                    outputBuffer.append ("{{NEWLINE}}");
                }

Maybe you are looking for

  • Not all songs are getting synced into my iPhone

    Why is this? I have no clue. Only ~200 of my ~500 songs are getting uploaded. Also, what's the best way to store songs in my computer, such that it will not get duplicated on my iTunes and/or iPhone? Currently, I store the song as "Led Zeppelin - Sta

  • Mystical PL/SQL Error(?!)

    Greetings! I've a procedure and a trigger. The problem is when I call the proc from inside the trigger I get an error message saying that Error: ORA-00604: error occurred at recursive SQL level 1 ORA-20001: Unhandled error occured! ORA-06512: at "ITE

  • Problem with loading native library in java version "1.5.0_05"

    My application uses a native coded drawing. With java version 1.4.xx it was working just fine but with java 1.5.xx it gives the following error at the time of loading native library: java.lang.UnsatisfiedLinkError: /home/abyzov/tmp/friend32-1.6.02/li

  • Adobe Captivate 7 patch (CP 7.0.1)

    Adobe Captivate 7.0.1 patch is released now. Downloading instruction and What's new in Adobe Captivate 7 : http://helpx.adobe.com/captivate/kb/captivate-7-patch.html Mac users may share his/her contact details on [email protected] and we will share C

  • Notification: Free Reference Object (BADI)

    Hi All, When we define Screen areas in Notification Header for any notification type, in Screen Type Object drop down there option O550 Object: Free Reference Object (BADI). Can anyone tell: 1. What is the meaning of it 2. Does this changes the optio