Java Utililty Methods Unzip File

List of utility methods to do Unzip File

Description

The list of methods to do Unzip File are organized into topic(s).

Method

voidunzip(File zippedFile, File outputDirectory)
Unzips a file to an output directory
Set<String> added = new HashSet<String>();
ZipInputStream inStream = null;
try {
    inStream = new ZipInputStream(new FileInputStream(zippedFile));
    ZipEntry entry;
    byte[] buffer = new byte[1024];
    while ((entry = inStream.getNextEntry()) != null) {
        String name = entry.getName();
...
voidunzip(File zippedFile, File targetDir)
unzip
targetDir.mkdirs();
ZipFile zipFile = new ZipFile(zippedFile);
try {
    Enumeration<? extends ZipEntry> entries = zipFile.entries();
    while (entries.hasMoreElements()) {
        ZipEntry entry = entries.nextElement();
        File targetFile = new File(targetDir, entry.getName());
        if (entry.isDirectory()) {
...
Mapunzip(final byte[] zippedContent)
unzip
final ZipInputStream zis = new ZipInputStream(new ByteArrayInputStream(zippedContent));
final Map<String, byte[]> resources = new HashMap<String, byte[]>();
try {
    ZipEntry entry = zis.getNextEntry();
    while (entry != null) {
        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
        try {
            int len;
...
voidunzip(final File dir, final ZipInputStream from)
Copy a zip stream to the given directory.
ZipEntry entry;
while ((entry = from.getNextEntry()) != null) {
    if (entry.isDirectory()) {
        new File(dir, entry.getName()).mkdirs();
    } else {
        final File file = new File(dir, entry.getName());
        file.getParentFile().mkdirs();
        file.createNewFile();
...
voidunzip(final File zip, final File dir)
unzip
if (!zip.exists())
    throw new FileNotFoundException("Cannot find " + zip);
if (!dir.exists())
    throw new FileNotFoundException("Cannot find " + dir);
if (!zip.isFile())
    throw new FileNotFoundException("Zip file must be a file " + zip);
if (!dir.isDirectory())
    throw new FileNotFoundException("Dir argument must be a directory " + dir);
...
booleanunzip(final File zipFile, final File destDir)
Uncompresses the zip archive into the specified directory.
final String destDirAbsPath = destDir.getAbsolutePath() + File.separatorChar;
final byte[] buf = new byte[2048];
ZipInputStream ziStream = null;
FileInputStream fiStream = null;
try {
    fiStream = new FileInputStream(zipFile);
    ziStream = new ZipInputStream(fiStream);
    ZipEntry zipEntry = ziStream.getNextEntry();
...
voidunzip(final File zipFile, final String targetDir)
unzip
boolean MAC_OS_X = System.getProperty("os.name").toLowerCase().startsWith("mac os x");
int buf_size = 2048;
try {
    BufferedOutputStream dest; 
    FileInputStream fis = new FileInputStream(zipFile);
    ZipInputStream zis = new ZipInputStream(new BufferedInputStream(fis));
    ZipEntry entry;
    while ((entry = zis.getNextEntry()) != null) {
...
voidunzip(final InputStream is, final File outputDirectory)
Unzip a zip file in a directory.
if (is == null) {
    throw new IOException("The inputStream is null");
if (outputDirectory == null) {
    throw new IOException("The output directory is null");
if (!(outputDirectory.exists() && outputDirectory.isDirectory())) {
    throw new IOException("The output directory is invalid (" + outputDirectory + ")");
...
voidunzip(final InputStream zipFile, final File targetFolder)
Unzips a given ZIP file InputStream into a given target File folder .
if (targetFolder.exists()) {
    if (!targetFolder.isDirectory()) {
        throw new IllegalArgumentException(
                String.format("Given existing target folder '%1$s' is not a directory!", targetFolder));
} else {
    if (!targetFolder.mkdirs()) {
        throw new IOException(String.format("Could not create target folder '%1$s'!", targetFolder));
...
StringunZip(final String result)
un Zip
ByteArrayOutputStream fout = null;
try {
    final ByteArrayInputStream in = new ByteArrayInputStream(result.getBytes("ISO-8859-1"));
    final ZipInputStream zin = new ZipInputStream(in);
    while ((zin.getNextEntry()) != null) {
        fout = new ByteArrayOutputStream();
        for (int c = zin.read(); c != -1; c = zin.read()) {
            fout.write(c);
...