How to view files. zip using java for android

Asked

Viewed 62 times

-6

I wonder how I do a program that can view . zip files on android using java, I’ve been looking for a while and did not find ;(... If possible in the easiest way, if there is one...

Thank you!

  • I could explain better what it would be preview files. zip?

1 answer

2


Fala Drkill,

It really gets kind of hard to understand what your doubt, how so visualize?

You can dec a file, example:

private boolean unpackZip(String path, String zipname){       
     InputStream is;
     ZipInputStream zis;
     try 
     {
         String filename;
         is = new FileInputStream(path + zipname);
         zis = new ZipInputStream(new BufferedInputStream(is));          
         ZipEntry ze;
         byte[] buffer = new byte[1024];
         int count;

         while ((ze = zis.getNextEntry()) != null) 
         {
             // zapis do souboru
             filename = ze.getName();

             // Need to create directories if not exists, or
             // it will generate an Exception...
             if (ze.isDirectory()) {
                File fmd = new File(path + filename);
                fmd.mkdirs();
                continue;
             }

             FileOutputStream fout = new FileOutputStream(path + filename);

             // cteni zipu a zapis
             while ((count = zis.read(buffer)) != -1) 
             {
                 fout.write(buffer, 0, count);             
             }

             fout.close();               
             zis.closeEntry();
         }

         zis.close();
     } 
     catch(IOException e)
     {
         e.printStackTrace();
         return false;
     }

    return true;
}

But try to rephrase your question, then it’s easier to help you.

Hugs.

  • Thank you! That’s what I was looking for

Browser other questions tagged

You are not signed in. Login or sign up in order to post.