/** * Returns the full file path+names of all split zip files * in an ArrayList. For example: If a split zip file(abc.zip) has a 10 split parts * this method returns an array list with path + "abc.z01", path + "abc.z02", etc. * Returns null if the zip file does not exist * @return ArrayList of Strings * @throws ZipException */ public ArrayList getSplitZipFiles() throws ZipException { checkZipModel(); return Zip4jUtil.getSplitZipFiles(zipModel); }
/** * Returns the full file path+names of all split zip files * in an ArrayList. For example: If a split zip file(abc.zip) has a 10 split parts * this method returns an array list with path + "abc.z01", path + "abc.z02", etc. * Returns null if the zip file does not exist * @return ArrayList of Strings * @throws ZipException */ public ArrayList getSplitZipFiles() throws ZipException { checkZipModel(); return Zip4jUtil.getSplitZipFiles(zipModel); }
/** * Returns an input stream for reading the contents of the Zip file corresponding * to the input FileHeader. Throws an exception if the FileHeader does not exist * in the ZipFile * @param fileHeader * @return ZipInputStream * @throws ZipException */ public ZipInputStream getInputStream(FileHeader fileHeader) throws ZipException { if (fileHeader == null) { throw new ZipException("FileHeader is null, cannot get InputStream"); } checkZipModel(); if (zipModel == null) { throw new ZipException("zip model is null, cannot get inputstream"); } Unzip unzip = new Unzip(zipModel); return unzip.getInputStream(fileHeader); }
/** * Returns an input stream for reading the contents of the Zip file corresponding * to the input FileHeader. Throws an exception if the FileHeader does not exist * in the ZipFile * @param fileHeader * @return ZipInputStream * @throws ZipException */ public ZipInputStream getInputStream(FileHeader fileHeader) throws ZipException { if (fileHeader == null) { throw new ZipException("FileHeader is null, cannot get InputStream"); } checkZipModel(); if (zipModel == null) { throw new ZipException("zip model is null, cannot get inputstream"); } Unzip unzip = new Unzip(zipModel); return unzip.getInputStream(fileHeader); }
/** * Merges split zip files into a single zip file without the need to extract the * files in the archive * @param outputZipFile * @throws ZipException */ public void mergeSplitFiles(File outputZipFile) throws ZipException { if (outputZipFile == null) { throw new ZipException("outputZipFile is null, cannot merge split files"); } if (outputZipFile.exists()) { throw new ZipException("output Zip File already exists"); } checkZipModel(); if (this.zipModel == null) { throw new ZipException("zip model is null, corrupt zip file?"); } ArchiveMaintainer archiveMaintainer = new ArchiveMaintainer(); archiveMaintainer.initProgressMonitorForMergeOp(zipModel, progressMonitor); archiveMaintainer.mergeSplitZipFiles(zipModel, outputZipFile, progressMonitor, runInThread); }
/** * Internal method to add a folder to the zip file. * @param path * @param parameters * @param checkSplitArchive * @throws ZipException */ private void addFolder(NativeStorage path, ZipParameters parameters, boolean checkSplitArchive) throws ZipException { checkZipModel(); if (this.zipModel == null) { throw new ZipException("internal error: zip model is null"); } if (checkSplitArchive) { if (this.zipModel.isSplitArchive()) { throw new ZipException("This is a split archive. Zip file format does not allow updating split/spanned files"); } } ZipEngine zipEngine = new ZipEngine(zipModel); zipEngine.addFolderToZip(path, parameters, progressMonitor, runInThread); }
/** * Internal method to add a folder to the zip file. * @param path * @param parameters * @param checkSplitArchive * @throws ZipException */ private void addFolder(File path, ZipParameters parameters, boolean checkSplitArchive) throws ZipException { checkZipModel(); if (this.zipModel == null) { throw new ZipException("internal error: zip model is null"); } if (checkSplitArchive) { if (this.zipModel.isSplitArchive()) { throw new ZipException("This is a split archive. Zip file format does not allow updating split/spanned files"); } } ZipEngine zipEngine = new ZipEngine(zipModel); zipEngine.addFolderToZip(path, parameters, progressMonitor, runInThread); }
/** * Merges split zip files into a single zip file without the need to extract the * files in the archive * @param outputZipFile * @throws ZipException */ public void mergeSplitFiles(NativeStorage outputZipFile) throws ZipException { if (outputZipFile == null) { throw new ZipException("outputZipFile is null, cannot merge split files"); } if (outputZipFile.exists()) { throw new ZipException("output Zip File already exists"); } checkZipModel(); if (this.zipModel == null) { throw new ZipException("zip model is null, corrupt zip file?"); } ArchiveMaintainer archiveMaintainer = new ArchiveMaintainer(); archiveMaintainer.initProgressMonitorForMergeOp(zipModel, progressMonitor); archiveMaintainer.mergeSplitZipFiles(zipModel, outputZipFile, progressMonitor, runInThread); }
checkZipModel(); } else { throw new ZipException("zip file does not exist, cannot read comment");
checkZipModel(); } else { throw new ZipException("zip file does not exist, cannot read comment");