ZipUtils { public static File getFileFrom(File zip, String targetPathInZipfile, File destFolder) { File target = null; try { Zip64File zip64File = new Zip64File(zip); FileEntry targetEntry = getFileEntry(zip64File, targetPathInZipfile); if(targetEntry!=null) { target = readEntry(zip64File, targetEntry, destFolder); } else { log.severe("[getFileFrom] Sorry, the file/folder you ask for could not be found in this zip: " + targetPathInZipfile); } } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return target; }  static File createZip(File srcFolder, File destFolder, String zipName, boolean compress); static ZipResult createZipAndCheck(File srcFolder, File destFolder, String zipName, boolean compress); @SuppressWarnings("unchecked") static List<File> unzipTo(File zipFile, File destFolder); static List<File> checkAndUnzipTo(File zipFile, File destFolder, Checksum checksum); static String[] getAllFragments(File zip); static File getFileFrom(File zip, String targetPathInZipfile, File destFolder); static File insertFileInto(File zipFile, File toInsert, String targetPath); static File removeFileFrom(File zipFile, String fileToRemove); @SuppressWarnings("unchecked") static boolean isZipFile(File file); @SuppressWarnings("unchecked") static List<String> listZipEntries(File zip);  }
@Test public void testGetFileFrom() throws IOException { FileUtils.cleanDirectory(outputFolder); File zip = ZipUtils.createZip(TEST_FILE_FOLDER, outputFolder, "zipUtilsTestGetFile.zip", true); System.out.println("Zip created. Please find it here: " + zip.getAbsolutePath()); File fromZip = ZipUtils.getFileFrom(zip, "docs", outputFolder); System.out.println("File extracted. Please find it here: " + fromZip.getAbsolutePath()); }