/** * Extracts a specific file from the zip file to the destination path. * If destination path is invalid, then this method throws an exception. * @param fileHeader * @param destPath * @throws ZipException */ public void extractFile(FileHeader fileHeader, String destPath) throws ZipException { extractFile(fileHeader, destPath, null); }
/** * Extracts a specific file from the zip file to the destination path. * If destination path is invalid, then this method throws an exception. * @param fileHeader * @param destPath * @throws ZipException */ public void extractFile(FileHeader fileHeader, String destPath) throws ZipException { extractFile(fileHeader, destPath, null); }
/** * Extracts a specific file from the zip file to the destination path. * If destination path is invalid, then this method throws an exception. * <br><br> * If newFileName is not null or empty, newly created file name will be replaced by * the value in newFileName. If this value is null, then the file name will be the * value in FileHeader.getFileName * @param fileHeader * @param destPath * @param unzipParameters * @throws ZipException */ public void extractFile(FileHeader fileHeader, String destPath, UnzipParameters unzipParameters) throws ZipException { extractFile(fileHeader, destPath, unzipParameters, null); }
/** * Extracts a specific file from the zip file to the destination path. * If destination path is invalid, then this method throws an exception. * <br><br> * If newFileName is not null or empty, newly created file name will be replaced by * the value in newFileName. If this value is null, then the file name will be the * value in FileHeader.getFileName * @param fileHeader * @param destPath * @param unzipParameters * @throws ZipException */ public void extractFile(FileHeader fileHeader, String destPath, UnzipParameters unzipParameters) throws ZipException { extractFile(fileHeader, destPath, unzipParameters, null); }
/** * Extracts a specific file from the zip file to the destination path. * This method first finds the necessary file header from the input file name. * <br><br> * File name is relative file name in the zip file. For example if a zip file contains * a file "a.txt", then to extract this file, input file name has to be "a.txt". Another * example is if there is a file "b.txt" in a folder "abc" in the zip file, then the * input file name has to be abc/b.txt * <br><br> * Throws an exception if file header could not be found for the given file name or if * the destination path is invalid * @param fileName * @param destPath * @throws ZipException */ public void extractFile(String fileName, String destPath) throws ZipException { extractFile(fileName, destPath, null); }
/** * Extracts a specific file from the zip file to the destination path. * This method first finds the necessary file header from the input file name. * <br><br> * File name is relative file name in the zip file. For example if a zip file contains * a file "a.txt", then to extract this file, input file name has to be "a.txt". Another * example is if there is a file "b.txt" in a folder "abc" in the zip file, then the * input file name has to be abc/b.txt * <br><br> * Throws an exception if file header could not be found for the given file name or if * the destination path is invalid * @param fileName * @param destPath * @throws ZipException */ public void extractFile(String fileName, String destPath) throws ZipException { extractFile(fileName, destPath, null); }
/** * Extracts a specific file from the zip file to the destination path. * This method first finds the necessary file header from the input file name. * <br><br> * File name is relative file name in the zip file. For example if a zip file contains * a file "a.txt", then to extract this file, input file name has to be "a.txt". Another * example is if there is a file "b.txt" in a folder "abc" in the zip file, then the * input file name has to be abc/b.txt * <br><br> * Throws an exception if file header could not be found for the given file name or if * the destination path is invalid * @param fileName * @param destPath * @param unzipParameters * @throws ZipException */ public void extractFile(String fileName, String destPath, UnzipParameters unzipParameters) throws ZipException { extractFile(fileName, destPath, unzipParameters, null); }
/** * Extracts a specific file from the zip file to the destination path. * This method first finds the necessary file header from the input file name. * <br><br> * File name is relative file name in the zip file. For example if a zip file contains * a file "a.txt", then to extract this file, input file name has to be "a.txt". Another * example is if there is a file "b.txt" in a folder "abc" in the zip file, then the * input file name has to be abc/b.txt * <br><br> * Throws an exception if file header could not be found for the given file name or if * the destination path is invalid * @param fileName * @param destPath * @param unzipParameters * @throws ZipException */ public void extractFile(String fileName, String destPath, UnzipParameters unzipParameters) throws ZipException { extractFile(fileName, destPath, unzipParameters, null); }
@Override public void extractTo(DirectoryResource directoryResource) { try { UnzipParameters parameters = new UnzipParameters(); getZipFile().extractFile(fileHeader, directoryResource.getFullyQualifiedName(), parameters); } catch (ZipException e) { throw new ResourceException("Error while fetching zip contents", e); } }
@Override public void extractTo(DirectoryResource directoryResource, String newName) { try { UnzipParameters parameters = new UnzipParameters(); getZipFile().extractFile(fileHeader, directoryResource.getFullyQualifiedName(), parameters, newName); } catch (ZipException e) { throw new ResourceException("Error while fetching zip contents", e); } }
for (int i = 0; i < zipFile.getFileHeaders().size(); i++) { fileHeader = (FileHeader) zipFile.getFileHeaders().get(i); zipFile.extractFile(fileHeader, outputPath); int progress = (int) ((i + 1) * 1.0 * 100 / total); if (progress == progressNow) {//此时与上次相同,就不反复监听了
private void expandVertexiumPlugin(File vertexiumPluginDir) { InputStream zipIn = getClass().getResourceAsStream("/vertexium-elasticsearch5-plugin.zip"); File pluginZip = new File(vertexiumPluginDir.getParentFile(), "vertexium-elasticsearch5-plugin.zip"); try (OutputStream zipOut = new FileOutputStream(pluginZip)) { IOUtils.copy(zipIn, zipOut); } catch (Exception ex) { throw new VertexiumException("Could not write plugin zip file", ex); } try { ZipFile zipFile = new ZipFile(pluginZip); zipFile.extractFile("elasticsearch/plugin-descriptor.properties", vertexiumPluginDir.getAbsolutePath(), null, "plugin-descriptor.properties"); } catch (Exception ex) { throw new VertexiumException("Could not extract plugin", ex); } pluginZip.delete(); }
if (iof != -1) name = name.substring(iof + 1); zipFile.extractFile(fileHeader, ListWithCustomSetting.getCustomFilesDir(context).getAbsolutePath(), null, name); try { File extractTo = themeManager.getThemePath(UUID.fromString(uuid)); zipFile.extractFile(fileHeader, extractTo.getParentFile().getAbsolutePath(), null, extractTo.getName()); } catch (IllegalArgumentException e) { SettingsHelper.deleteSQLiteDatabase(NotificationCountStorage.getFile(context)); try { zipFile.extractFile(NOTIFICATION_COUNT_DB_PATH, ListWithCustomSetting.getCustomFilesDir(context).getAbsolutePath(), null, NotificationCountStorage.getFile(context).getAbsolutePath());