Java Code Examples for net.lingala.zip4j.progress.ProgressMonitor#STATE_BUSY
The following examples show how to use
net.lingala.zip4j.progress.ProgressMonitor#STATE_BUSY .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ZipFile.java From AndroidZip with Apache License 2.0 | 6 votes |
/** * 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 * @param unzipParameters * @param newFileName * @throws ZipException */ public void extractFile(FileHeader fileHeader, String destPath, UnzipParameters unzipParameters, String newFileName) throws ZipException { if (fileHeader == null) { throw new ZipException("input file header is null, cannot extract file"); } if (!Zip4jUtil.isStringNotNullAndNotEmpty(destPath)) { throw new ZipException("destination path is empty or null, cannot extract file"); } readZipInfo(); if (progressMonitor.getState() == ProgressMonitor.STATE_BUSY) { throw new ZipException("invalid operation - Zip4j is in busy state"); } fileHeader.extractFile(zipModel, destPath, unzipParameters, newFileName, progressMonitor, runInThread); }
Example 2
Source File: ZipFile.java From AndroidZip with Apache License 2.0 | 5 votes |
/** * Adds the list of input files to the zip file. If zip file does not exist, then * this method creates a new zip file. Parameters such as compression type, etc * can be set in the input parameters. * @param sourceFileList * @param parameters * @throws ZipException */ public void addFiles(ArrayList sourceFileList, ZipParameters parameters) throws ZipException { checkZipModel(); if (this.zipModel == null) { throw new ZipException("internal error: zip model is null"); } if (sourceFileList == null) { throw new ZipException("input file ArrayList is null, cannot add files"); } if (!Zip4jUtil.checkArrayListTypes(sourceFileList, InternalZipConstants.LIST_TYPE_FILE)) { throw new ZipException("One or more elements in the input ArrayList is not of type File"); } if (parameters == null) { throw new ZipException("input parameters are null, cannot add files to zip"); } if (progressMonitor.getState() == ProgressMonitor.STATE_BUSY) { throw new ZipException("invalid operation - Zip4j is in busy state"); } if (Zip4jUtil.checkFileExists(file)) { if (zipModel.isSplitArchive()) { throw new ZipException("Zip file already exists. Zip file format does not allow updating split/spanned files"); } } ZipEngine zipEngine = new ZipEngine(zipModel); zipEngine.addFiles(sourceFileList, parameters, progressMonitor, runInThread); }
Example 3
Source File: ZipFile.java From AndroidZip with Apache License 2.0 | 5 votes |
/** * Extracts all the files in the given zip file to the input destination path. * If zip file does not exist or destination path is invalid then an * exception is thrown. * @param destPath * @param unzipParameters * @throws ZipException */ public void extractAll(String destPath, UnzipParameters unzipParameters) throws ZipException { if (!Zip4jUtil.isStringNotNullAndNotEmpty(destPath)) { throw new ZipException("output path is null or invalid"); } if (!Zip4jUtil.checkOutputFolder(destPath)) { throw new ZipException("invalid output path"); } if (zipModel == null) { readZipInfo(); } // Throw an exception if zipModel is still null if (zipModel == null) { throw new ZipException("Internal error occurred when extracting zip file"); } if (progressMonitor.getState() == ProgressMonitor.STATE_BUSY) { throw new ZipException("invalid operation - Zip4j is in busy state"); } Unzip unzip = new Unzip(zipModel); unzip.extractAll(unzipParameters, destPath, progressMonitor, runInThread); }
Example 4
Source File: ZipFile.java From AndroidZip with Apache License 2.0 | 5 votes |
/** * 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> * 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 * <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 * @param newFileName * @throws ZipException */ public void extractFile(String fileName, String destPath, UnzipParameters unzipParameters, String newFileName) throws ZipException { if (!Zip4jUtil.isStringNotNullAndNotEmpty(fileName)) { throw new ZipException("file to extract is null or empty, cannot extract file"); } if (!Zip4jUtil.isStringNotNullAndNotEmpty(destPath)) { throw new ZipException("destination string path is empty or null, cannot extract file"); } readZipInfo(); FileHeader fileHeader = Zip4jUtil.getFileHeader(zipModel, fileName); if (fileHeader == null) { throw new ZipException("file header not found for given file name, cannot extract file"); } if (progressMonitor.getState() == ProgressMonitor.STATE_BUSY) { throw new ZipException("invalid operation - Zip4j is in busy state"); } fileHeader.extractFile(zipModel, destPath, unzipParameters, newFileName, progressMonitor, runInThread); }