×

Discussion Board

Results 1 to 2 of 2

Hybrid View

  1. #1
    Registered User
    Join Date
    Aug 2012
    Posts
    12

    AM UNABLE TO CREATE ZIP IN JAZZLIB USING ZipOutputStream

    I tried using the jazzlib library to create a zip file but i only get PK when i finished. I tried different string but i got the same result. Here is my code: import net.sf.jazzlib.*;
    import java.io.*;

    public class e {

    public static byte[] compress(String data) throws IOException {
    byte[] value = data.getBytes();
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    ZipOutputStream zos = new ZipOutputStream(bos);
    ZipEntry ze = new ZipEntry("msg.gz");
    long length = value.length;
    ze.setSize(length);
    zos.putNextEntry(ze);
    zos.setMethod(ZipOutputStream.DEFLATED);

    zos.write(value, 0, value.length);

    zos.closeEntry();
    zos.close();
    byte[] values = bos.toByteArray();
    bos.close();
    return values;
    }
    }
    . I call the code with try { e.compress("messages"); } catch(Exception e) { } . Please help me.

  2. #2
    Registered User
    Join Date
    Sep 2012
    Posts
    31

    Re: AM UNABLE TO CREATE ZIP IN JAZZLIB USING ZipOutputStream

    Quote Originally Posted by elvis10ten View Post
    I tried using the jazzlib library to create a zip file but i only get PK when i finished. I tried different string but i got the same result. Here is my code: import net.sf.jazzlib.*;
    import java.io.*;

    public class e {

    public static byte[] compress(String data) throws IOException {
    byte[] value = data.getBytes();
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    ZipOutputStream zos = new ZipOutputStream(bos);
    ZipEntry ze = new ZipEntry("msg.gz");
    long length = value.length;
    ze.setSize(length);
    zos.putNextEntry(ze);
    zos.setMethod(ZipOutputStream.DEFLATED);

    zos.write(value, 0, value.length);

    zos.closeEntry();
    zos.close();
    byte[] values = bos.toByteArray();
    bos.close();
    return values;
    }
    }
    . I call the code with try { e.compress("messages"); } catch(Exception e) { } . Please help me.
    I used the jazz lib for j2me and able to generate a zip file .
    The steps i followed is
    1.Create file connection object
    2. ZipOutputStream zos = new ZipOutputStream(filconnection.openDataoutputstream);
    3.Remaining steps as you did .
    Regards,
    Venkatesh

Similar Threads

  1. J2ME JAZZLIB PREVERIFICATION HELP
    By elvis10ten in forum Mobile Java General
    Replies: 10
    Last Post: 2012-10-16, 11:59
  2. unable to create sis file...
    By s4sandy_bit in forum Symbian
    Replies: 14
    Last Post: 2008-11-13, 06:00
  3. Unable to create file
    By Ajmal in forum Symbian Media (Closed)
    Replies: 4
    Last Post: 2008-06-05, 04:39
  4. Unable to create new project
    By Deepa msc in forum General Development Questions
    Replies: 1
    Last Post: 2008-01-08, 14:17

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •