×

Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 28
  1. #1
    Regular Contributor
    Join Date
    Mar 2010
    Posts
    70

    Need Help about compressed data before sending to server

    hi

    i want to compressed data before sending to the server is there is any library available in j2me .so please let me know
    I am very thankful to you

    Regards
    Junaid Mohiuddidn

  2. #2
    Nokia Developer Champion
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    3,087

    Re: Need Help about compressed data before sending to server

    Use jzlib ported for J2ME available
    at

    http://www.jcraft.org

    or

    http://www.java4ever.com/index.php?s...=main&lang=_en

    thanks,
    ~Amitabh

  3. #3
    Regular Contributor
    Join Date
    Mar 2010
    Posts
    70

    Re: Need Help about compressed data before sending to server

    Thanks for reply

    But the second link contain the gzip.zip that contain only decompress file

    Regards
    Junaid

  4. #4
    Nokia Developer Champion
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    3,087

    Re: Need Help about compressed data before sending to server

    The first one can be used to compress the data to gzip outstream for sendingto server.

    thanks,
    ~Amitabh

  5. #5
    Regular Contributor
    Join Date
    Mar 2010
    Posts
    70

    Re: Need Help about compressed data before sending to server

    hi
    the first link is for some Japanese stuff .please tell me the right link
    Thanks
    Regads
    Junaid

  6. #6
    Super Contributor
    Join Date
    Mar 2008
    Location
    The Capital of INDIA
    Posts
    4,328

    Re: Need Help about compressed data before sending to server

    Quote Originally Posted by junaid888 View Post
    hi
    the first link is for some Japanese stuff .please tell me the right link
    Thanks
    Regads
    Junaid
    Hey come on dear,
    there is also the option of the English at the right tab.just click the same.
    Thanks with Regards,

    R a j - The K e r n e l


    Join Delhi-NCR Nokia Developer's Community,

  7. #7
    Regular Contributor
    Join Date
    Mar 2010
    Posts
    70

    Re: Need Help about compressed data before sending to server

    ok
    i used to example in jzlib folder but it will not compressed the size of string bytes &n the length of the string bytes array will still same

    Reagards
    Juanid

  8. #8
    Nokia Developer Champion
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    3,087

    Re: Need Help about compressed data before sending to server

    What COMPRESSION level are you trying ?

    I have tried -

    ZOutputStream outputStream = new ZOutputStream(stream, ZStream.Z_DEFAULT_COMPRESSION, false);

    It helped to reduce the xml data size in bytes that I was passing over to the server.

    thanks,
    ~Amitabh

  9. #9
    Regular Contributor
    Join Date
    Mar 2010
    Posts
    70

    Re: Need Help about compressed data before sending to server

    hi
    i am not sending the xml data to the server .I send the bytes array i just want to compressed the size of the byte array then i send it to the server & on server side i decompressed it.

  10. #10
    Nokia Developer Champion
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    3,087

    Re: Need Help about compressed data before sending to server

    try this:
    PHP Code:
       // use this method to compress using jzib         
       // print the size of output Array, compression will depend on data type, if its already compressed bytes like JEPG or MPGE or MP3 data you will not see much compression, if the Uncompressed byte[] consist of text or XML then you will see the byte[]

       
    private byte[] Compress(byte [] Uncompressed)
        {
           try
           {
                
    System.out.println("Orginal size: "+Uncompressed.length);
                
    ByteArrayOutputStream stream = new ByteArrayOutputStream();

                
    ZOutputStream outputStream = new ZOutputStream(streamZStream.Z_DEFAULT_COMPRESSIONfalse);

                
    outputStream.write(Uncompressed);
                
    outputStream.flush();
                
    outputStream.close();

                return 
    stream.toByteArray();

           }
           catch ( 
    Exception e )
           { 
            
    System.out.println("Error");
           } 
    thanks,
    ~Amitabh

  11. #11
    Regular Contributor
    Join Date
    Mar 2010
    Posts
    70

    Re: Need Help about compressed data before sending to server

    Thanks for code


    for uncompressed the array we used the Zinputstream from server side?or the gzip inflate method

  12. #12
    Nokia Developer Champion
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    3,087

    Re: Need Help about compressed data before sending to server

    Zinputstream works good, its standard if you are using java server.

    thanks,
    ~Amitabh

  13. #13
    Regular Contributor
    Join Date
    Mar 2010
    Posts
    70

    Re: Need Help about compressed data before sending to server

    yes i am using servlet as a server.
    i will go with this process for uncompress the byte array on server.

    1)first i get the compressed byte array through http conection
    2)then i pass the compress byte array the bytearrayinptstream

    ByteArrayInputStream bais=new ByteArrayInputStream(compressedbytearray);

    3)then when i pass the ByteArrayInputStream to the Zinputstream contructor it will not accept the bytearrayinputstream object to the Zinputstream cnstructor.

    ZInputStream zis=new ZInputStream(bais);

  14. #14
    Nokia Developer Champion
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    3,087

    Re: Need Help about compressed data before sending to server

    Use this constructor:

    ZInputStream outputStream = new ZInputStream(bais, false);

    Now read outputStream for uncompressed data bytes.

    thanks,
    ~Amitabh

  15. #15
    Regular Contributor
    Join Date
    Mar 2010
    Posts
    70

    Re: Need Help about compressed data before sending to server

    here
    "is" is InputStream

    or

    Inputestream=request.getinputstream

Similar Threads

  1. Some data lost while receiving data from server
    By 182guide in forum Symbian Networking & Messaging (Closed)
    Replies: 5
    Last Post: 2010-03-09, 20:04
  2. Sending information from file to a server?
    By SanjayKhuntia in forum Symbian Networking & Messaging (Closed)
    Replies: 6
    Last Post: 2008-08-25, 15:59
  3. Sending allot of data by http
    By jaazz in forum Mobile Java Networking & Messaging & Security
    Replies: 1
    Last Post: 2007-03-12, 09:53
  4. GPRS connection problems on 6600..
    By suckho in forum Symbian Networking & Messaging (Closed)
    Replies: 10
    Last Post: 2005-12-02, 14:00
  5. Gauge to monitor progress not working :(
    By mattsaccount in forum Mobile Java General
    Replies: 1
    Last Post: 2004-05-17, 02:07

Posting Permissions

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