Discussion Board

Results 1 to 12 of 12
  1. #1
    Registered User
    Join Date
    May 2009
    Posts
    5

    Extracting ZIP file in J2ME

    Hi,
    I have a zip file (which contains xml files and images) over a httpconnection.
    Is it possible to extract that ZIP file with a j2me application and save the contents in phone memory (RMS) ?
    I need it very urgent..

    Thanks,
    Srinivas

  2. #2
    Super Contributor
    Join Date
    Apr 2009
    Posts
    572

    Re: Extracting ZIP file in J2ME

    by default j2me doesnt provide any class to extract a zip file what you can try is this
    Regards,
    Saurabh

  3. #3
    Registered User
    Join Date
    Mar 2009
    Posts
    18

    Re: Extracting ZIP file in J2ME

    i would suggest JZlib, it uses more friendly license.

  4. #4
    Registered User
    Join Date
    Dec 2011
    Posts
    1

    Re: Extracting ZIP file in J2ME

    Hi,

    Just go through this link. Its Working for me. Just try it
    http://surendranmca.blogspot.in/2011...mport-net.html


    Thanks,
    Ranjith

  5. #5
    Registered User
    Join Date
    Mar 2014
    Posts
    4

    Re: Extracting ZIP file in J2ME

    Hi,
    I have used zipMe library to unzip a zip folder(containing xml files and images) downloaded over httpConnection and saved in phone memory. But its giving me the following exception when i run it on emulator

    net.sf.zipme.ZipException: Deflated stream ends early.
    - net.sf.zipme.InflaterInputStream.fill(), bci=51
    - net.sf.zipme.InflaterInputStream.read(), bci=95
    - net.sf.zipme.ZipInputStream.read(), bci=68
    - net.sf.zipme.ZipInputStream.read(), bci=8
    - com.evampsaanga.mtnworldapp.UnZip.unZip(UnZip.java:133)
    - com.evampsaanga.mtnworldapp.UnZip.<init>(UnZip.java:25)
    - com.evampsaanga.mtnworldapp.Main.startApp(Main.java:60)
    - javax.microedition.midlet.MIDletTunnelImpl.callStartApp(), bci=1
    - com.sun.midp.midlet.MIDletPeer.startApp(), bci=4
    - com.sun.midp.midlet.MIDletStateHandler.startSuite(), bci=269
    - com.sun.midp.main.AbstractMIDletSuiteLoader.startSuite(), bci=38
    - com.sun.midp.main.CldcMIDletSuiteLoader.startSuite(), bci=5
    - com.sun.midp.main.AbstractMIDletSuiteLoader.runMIDletSuite(), bci=151
    - com.sun.midp.main.AppIsolateMIDletSuiteLoader.main(), bci=26

    Here is my code to unzip:

    public void unZip() throws IOException{

    ZipInputStream zis = null ;
    FileConnection fconn = null;

    try{
    String url = System.getProperty("fileconn.dir.photos")+"MTNData/xmlfile.zip";
    fconn = (FileConnection) Connector.open(url ,Connector.READ);

    zis = new ZipInputStream(fconn.openInputStream());
    ZipEntry current_zip_entry = null;

    while( ( current_zip_entry = zis.getNextEntry() ) != null )
    {
    System.out.println( current_zip_entry.getName() );
    ByteArrayOutputStream output = new ByteArrayOutputStream();

    int data = 0;
    while( ( data = zis.read() ) != -1 )
    {
    output.write( data );
    }


    // The ZipEntry is extracted in the output
    output.close();
    }


    } catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
    finally{
    if (zis != null)
    {zis.close();}
    if (fconn != null)
    {fconn.close(); }

    }

    }

    The size of my Zip folder is 525MB and after extraction it is about 800MB.
    My code is working fine on Nokia X2 but on Nokia express Music its giving out of memory exception after extracting 1 image . What can be the reason for this exception?

    Regards
    Sana Tanvir
    Last edited by EvampSaanga; 2014-03-10 at 07:22.

  6. #6
    Nokia Developer Champion
    Join Date
    Mar 2013
    Posts
    686

    Re: Extracting ZIP file in J2ME

    EvampSaanga, Welcome to the Nokia developer DiBo.
    As you can see this thread is several years old and is probably not monitored by its posters, in the future please refrain from digging up and posting in ancient discussion threads and simply open a new thread.

    As for your question the X2 is a Series40 device with limited heap memory capabilities (under 2MB of heap) so I doubt that you can extract 525MB zip file with it, as for Nokia expressmusic (there are several models with that name so you should be more specific, is it the 5800? is it the 5130? etc)

    In anycase if you have to download HUGE amount of data to the phone and ur zip size is 525MB and unzipped size is 800MB then I think you can just download the unzip files directly and thus avoid the unzipping them on the device.
    Heard of DVLUP? Join here

  7. #7
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Budapest, Hungary
    Posts
    28,808

    Re: Extracting ZIP file in J2ME

    Shai.i: EvampSaanga writes completely the opposite; that extraction actually works on the Nokia X2 and runs out of memory on the unspecified XpressMusic.

  8. #8
    Registered User
    Join Date
    Mar 2014
    Posts
    4

    Re: Extracting ZIP file in J2ME

    Thanks for your rply Shai

    I will start a new thread for my queries in future.

    I am using Nokia 5130 express music which is also a series 40 device.

    I am downloading the zip file from url and saving it in phone memory.Is it possible to read data directly from zip file saved in memory without extracting it? Can you please give some sample code for that?

    What can be the reason for the emulator error "Deflated stream ends early"? when no such error come on real device?

  9. #9
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Budapest, Hungary
    Posts
    28,808

    Re: Extracting ZIP file in J2ME

    For the Deflated stream ends early error, a first guess would be: only a part of the .zip file is received, and thus the compressed stream ends unexpectedly. Checking the size of the stored files should quickly reveal if this is the case.

  10. #10
    Registered User
    Join Date
    Mar 2014
    Posts
    4

    Re: Extracting ZIP file in J2ME

    while( ( current_zip_entry = zis.getNextEntry() ) != null )
    {
    int size = (int) current_zip_entry.getSize();
    System.out.println( current_zip_entry.getName()+size);
    }

    The size returned is -1 .
    -1 is returned when the size of zip file is unknown . What can be the reason for it?

  11. #11
    Nokia Developer Champion
    Join Date
    Mar 2013
    Posts
    686

    Re: Extracting ZIP file in J2ME

    The 5130 is a much older device than the X2 so I suspect that the X2 jvm and heap usage are more optimize which causes your OOM on the 5130.
    The "Deflated stream ends early" is indeed when you trying to unzip a not fully downloaded zip file.
    you can always "read" data from a zip file as a normal file without unzipping it but would that data have any meaning that's another story.
    Perhaps you run out of place in the emulator file system when trying to download the file and not all of it got downloaded.
    Heard of DVLUP? Join here

  12. #12
    Registered User
    Join Date
    Mar 2014
    Posts
    4

    Re: Extracting ZIP file in J2ME

    In this case if it will help if i download my zip files in small chunks save them in memory and then unzip these small chunks in phone memory and read them?

Similar Threads

  1. application error with 3gp file in J2ME
    By ruchig_iic in forum Mobile Java Media (Graphics & Sounds)
    Replies: 10
    Last Post: 2012-01-16, 22:40
  2. carbide.j v1.5 corrupt zip file
    By wez_81 in forum Tools and SDK Feedback (Closed)
    Replies: 6
    Last Post: 2006-11-29, 02:01
  3. Replies: 5
    Last Post: 2006-10-12, 09:41
  4. S60 theme questions
    By Nokian_Spb in forum Symbian Media (Closed)
    Replies: 3
    Last Post: 2006-08-17, 06:11

Posting Permissions

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