Here you can find the source of unzip(final File zipFile, final String suffix)
private static File unzip(final File zipFile, final String suffix) throws Exception
//package com.java2s; //License from project: Open Source License import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.nio.file.Files; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; public class Main { private static final int BUFFER = 2048; private static File unzip(final File zipFile, final String suffix) throws Exception { File ret = null;/*from w ww . jav a 2 s. co m*/ try (final FileInputStream fis = new FileInputStream(zipFile); final ZipInputStream zis = new ZipInputStream(new BufferedInputStream(fis))) { ZipEntry entry; while ((entry = zis.getNextEntry()) != null) { if (entry.getName().endsWith(suffix)) { ret = Files.createTempFile(entry.getName() + "-", suffix).toFile(); ret.deleteOnExit(); try (final FileOutputStream fos = new FileOutputStream(ret); final BufferedOutputStream dest = new BufferedOutputStream(fos, BUFFER)) { int count; final byte[] data = new byte[BUFFER]; while ((count = zis.read(data, 0, BUFFER)) != -1) { dest.write(data, 0, count); } dest.flush(); } break; } } } return ret; } }