Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Highlighted
New Contributor
Posts: 2
Registered: ‎08-19-2011
My Device: 8520
My Carrier: Tim

Re: How to extract a ZIP file (incl. folder structure) in RIM's JavaAPI world - anybody have tried t

private static void unzipFiles(byte[] result) throws IOException {

          InputStream sbis = new ByteArrayInputStream(result);
          ZipEntry dataZE = null;
          ZipInputStream dataZIS = new ZipInputStream(sbis);

          Hashtable htSizes = new Hashtable();

          int count = 0;
         
          while ((dataZE = dataZIS.getNextEntry()) != null) {
         
               if (dataZE.isDirectory()) {
                    continue;
               }

               int size = (int) dataZE.getSize();
               // -1 means unknown size.
               if (size == -1) {
                  size = ((Integer) htSizes.get(dataZE.getName())).intValue();
               }

               byte[] b = new byte[(int) size];
               int rb = 0;
               int chunk = 0;
 
               while (((int) size - rb) > 0) {
                  chunk = dataZIS.read(b, rb, (int) size - rb);
                if (chunk == -1) {
                    break;
               }
               rb += chunk;
             }

            processZipEntry(dataZE, count, b);
            count++;
        }
}

 

private static void processZipEntry(ZipEntry entry, int count,byte[] data) {


         INodeObject objRet = null;
         String key = (entry.getName().toLowerCase()); 

        try {
             StringBuffer dataInfo = new StringBuffer();
             String zip = new String(data, "UTF-8");
             dataInfo.append(zip);
             

             //This is used to unzip plain text files (json, xml, txt)

             //TODO: Do your stuff
            
           }catch(Exception e){
                System.out.println("Error unzipping: " + key);
          }
}

 

Contributor
Posts: 21
Registered: ‎02-10-2012
My Device: 8520, 9790
My Carrier: Airtel

Re: How to extract a ZIP file (incl. folder structure) in RIM's JavaAPI world - anybody have tried t

Hello

 

I have used this code but zipme.jar its not working .. Showing error message - net.sf.zipme.CRC32: Error!: Missing stack map in: make_crc_table at label: 43

 

please help me..

I need to unzip my database file which is present on sdcard

 

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to extract a ZIP file (incl. folder structure) in RIM's JavaAPI world - anybody have tried t

I would get the ZipMe source and build it yourself.

 

You also might be able to use this:

http://supportforums.blackberry.com/t5/Java-Development/Unzip-zip-archive-with-sample-resource-insta...