Unzip internal storage without fully working

My file unpacks one folder and one file, but for some reason it doesn't unpack them. How can I do this so that it unpacks all the contents of the zip files?

public void unzip(String filepath, String filename, String unzip_path) throws IOException {
    InputStream is = new FileInputStream(filepath + filename);
    Log.d("1st", filepath + filename);
    ZipInputStream zis = new ZipInputStream(new BufferedInputStream(is));

    try {
        ZipEntry ze;
        while ((ze = zis.getNextEntry()) != null) {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            byte[] buffer = new byte[1024];
            int count;

            String filename_temp = ze.getName();
            File fmd = new File(unzip_path + filename_temp);
            Log.d("2nd", unzip_path + filename_temp);
            if (!fmd.getParentFile().exists()) {
                fmd.getParentFile().mkdirs();
            }

            FileOutputStream fout = new FileOutputStream(unzip_path + filename_temp);

            while ((count = zis.read(buffer)) != -1) {
                baos.write(buffer, 0, count);
                byte[] bytes = baos.toByteArray();
                fout.write(bytes);
                baos.reset();
            }

            fout.close();
            //}
        }
    } finally {
        zis.close();
    }
}

      

+3


source to share





All Articles