More blok unzip sketchware

Add sourcode 1


try{java.io.File outdir = new java.io.File(_dir);java.util.zip.ZipInputStream zin = new java.util.zip.ZipInputStream(new java.io.FileInputStream(_file_zip));java.util.zip.ZipEntry entry;String name, dir;while ((entry = zin.getNextEntry()) != null){name = entry.getName();if(entry.isDirectory()){mkdirs(outdir, name);continue;} /* this part is necessary because file entry can come before* directory entry where is file located* i.e.:* /foo/foo.txt* /foo/*/ dir = dirpart(name);if(dir != null)mkdirs(outdir, dir); extractFile(zin, outdir, name);}zin.close();}catch (java.io.IOException e){e.printStackTrace();}

Add sourcode 2


}private static void extractFile(java.util.zip.ZipInputStream in, java.io.File outdir, String name) throws java.io.IOException{byte[] buffer = new byte[4096];java.io.BufferedOutputStream out = new java.io.BufferedOutputStream(new java.io.FileOutputStream(new java.io.File(outdir, name)));int count = -1;while ((count = in.read(buffer)) != -1)out.write(buffer, 0, count);out.close();} private static void mkdirs(java.io.File outdir, String path){java.io.File d = new java.io.File(outdir, path);if(!d.exists())d.mkdirs();} private static String dirpart(String name){int s = name.lastIndexOf(java.io.File.separatorChar);return s == -1 ? null : name.substring(0, s);


Comments