本文整理匯總了Java中net.lingala.zip4j.exception.ZipException.printStackTrace方法的典型用法代碼示例。如果您正苦於以下問題:Java ZipException.printStackTrace方法的具體用法?Java ZipException.printStackTrace怎麽用?Java ZipException.printStackTrace使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.lingala.zip4j.exception.ZipException
的用法示例。
在下文中一共展示了ZipException.printStackTrace方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: unzip
import net.lingala.zip4j.exception.ZipException; //導入方法依賴的package包/類
@ProtoMethod(description = "Unzip a file into a folder", example = "")
@ProtoMethodParam(params = {"zipFile", "folder"})
public void unzip(final String src, final String dst, final ReturnInterface callback) {
Thread t = new Thread(new Runnable() {
@Override
public void run() {
try {
FileIO.unZipFile(getAppRunner().getProject().getFullPathForFile(src), getAppRunner().getProject().getFullPathForFile(dst));
returnValues(null, callback);
} catch (ZipException e) {
e.printStackTrace();
}
}
});
t.start();
}
示例2: compile
import net.lingala.zip4j.exception.ZipException; //導入方法依賴的package包/類
public static void compile(String pkgroot){
try {
File parent = new File(pkgroot).getParentFile();
String name = new File(pkgroot).getName() + ".atomx";
ZipFile zipFile = new ZipFile(new File(parent, name));
ZipParameters parameters = new ZipParameters();
parameters.setCompressionMethod(Zip4jConstants.COMP_DEFLATE);
parameters.setCompressionLevel(Zip4jConstants.DEFLATE_LEVEL_NORMAL);
parameters.setIncludeRootFolder(false);
zipFile.addFolder(pkgroot, parameters);
} catch (ZipException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
示例3: list
import net.lingala.zip4j.exception.ZipException; //導入方法依賴的package包/類
/**
* 解壓文件,注意該法方法並不是異步的
*
* @param zipFile 壓縮文件
* @param filter
* @return
*/
public static void list(File zipFile, FileFilter filter){
try {
if(!FileHelper.exists(zipFile)){
return;
}
ZipFile zip = new ZipFile(zipFile);
zip.setRunInThread(false);
// Get the list of file headers from the zip file
List fileHeaderList = zip.getFileHeaders();
// Loop through the file headers
for (int i = 0; i < fileHeaderList.size(); i++) {
// Extract the file to the specified destination
filter.handle(zip, (FileHeader) fileHeaderList.get(i));
}
} catch (ZipException e) {
e.printStackTrace();
}
}
示例4: AddFolder
import net.lingala.zip4j.exception.ZipException; //導入方法依賴的package包/類
public AddFolder() {
try {
// Initiate ZipFile object with the path/name of the zip file.
ZipFile zipFile = new ZipFile("c:\\ZipTest\\AddFolder.zip");
// Folder to add
String folderToAdd = "c:\\FolderToAdd";
// Initiate Zip Parameters which define various properties such
// as compression method, etc.
ZipParameters parameters = new ZipParameters();
// set compression method to store compression
parameters.setCompressionMethod(Zip4jConstants.COMP_DEFLATE);
// Set the compression level
parameters.setCompressionLevel(Zip4jConstants.DEFLATE_LEVEL_NORMAL);
// Add folder to the zip file
zipFile.addFolder(folderToAdd, parameters);
} catch (ZipException e) {
e.printStackTrace();
}
}
示例5: decompressZipFile
import net.lingala.zip4j.exception.ZipException; //導入方法依賴的package包/類
public void decompressZipFile(String appName, String filename, String password) {
String filePath = Environment.getExternalStorageDirectory() + "/" + appName;
try {
File src = new File(filePath, filename);
ZipFile zipFile = new ZipFile(src);
if (zipFile.isEncrypted())
zipFile.setPassword(password);
zipFile.extractAll(filePath);
} catch (ZipException e) {
e.printStackTrace();
}
}
示例6: zip
import net.lingala.zip4j.exception.ZipException; //導入方法依賴的package包/類
/**
* 使用給定密碼壓縮指定文件或文件夾到指定位置.
* <p>
* dest可傳最終壓縮文件存放的絕對路徑,也可以傳存放目錄,也可以傳null或者"".<br />
* 如果傳null或者""則將壓縮文件存放在當前目錄,即跟源文件同目錄,壓縮文件名取源文件名,以.zip為後綴;<br />
* 如果以路徑分隔符(File.separator)結尾,則視為目錄,壓縮文件名取源文件名,以.zip為後綴,否則視為文件名.
* @param src 要壓縮的文件或文件夾路徑
* @param dest 壓縮文件存放路徑
* @param isCreateDir 是否在壓縮文件裏創建目錄,僅在壓縮文件為目錄時有效.<br />
* 如果為false,將直接壓縮目錄下文件到壓縮文件.
* @param passwd 壓縮使用的密碼
* @return 最終的壓縮文件存放的絕對路徑,如果為null則說明壓縮失敗.
*/
public static String zip(String src, String dest, boolean isCreateDir, String passwd) {
File srcFile = new File(src);
File destFile = new File(dest);
dest = buildDestinationZipFilePath(srcFile, dest);
ZipParameters parameters = new ZipParameters();
parameters.setFileNameInZip(destFile.getName().substring(0,destFile.getName().lastIndexOf("."))+".log");
parameters.setCompressionMethod(Zip4jConstants.COMP_DEFLATE); // 壓縮方式
parameters.setSourceExternalStream(true);
parameters.setCompressionLevel(Zip4jConstants.DEFLATE_LEVEL_NORMAL); // 壓縮級別
if (!TextUtils.isEmpty(passwd)) {
parameters.setEncryptFiles(true);
parameters.setEncryptionMethod(Zip4jConstants.ENC_METHOD_STANDARD); // 加密方式
parameters.setPassword(passwd.toCharArray());
}
try {
ZipFile zipFile = new ZipFile(dest);
if (srcFile.isDirectory()) {
// 如果不創建目錄的話,將直接把給定目錄下的文件壓縮到壓縮文件,即沒有目錄結構
if (!isCreateDir) {
File [] subFiles = srcFile.listFiles();
ArrayList<File> temp = new ArrayList<File>();
Collections.addAll(temp, subFiles);
zipFile.addFiles(temp, parameters);
return dest;
}
zipFile.addFolder(srcFile, parameters);
} else {
zipFile.addFile(srcFile, parameters);
}
return dest;
} catch (ZipException e) {
e.printStackTrace();
}
return null;
}
示例7: repackCert
import net.lingala.zip4j.exception.ZipException; //導入方法依賴的package包/類
/**
* Jar sign creates CERT SF & RSA but some apk have different name like
* ABC.SF This module will rename the CERT.SF & CERT.RSA to the new
* certificate name
*
* @param newAPKPath
* Path of the modified apk
*/
public static void repackCert(String newAPKPath) {
try {
ZipFile zipFile = new ZipFile(newAPKPath);
zipFile.extractFile("META-INF" + File.separator + "CERT.RSA",
getProjectPath());
zipFile.extractFile("META-INF" + File.separator + "CERT.SF",
getProjectPath());
zipFile.removeFile("META-INF" + File.separator + "CERT.SF");
zipFile.removeFile("META-INF" + File.separator + "CERT.RSA");
File rsaFile = new File(getProjectPath() + File.separator
+ "META-INF" + File.separator + "CERT.RSA");
File sfFile = new File(getProjectPath() + File.separator
+ "META-INF" + File.separator + "CERT.SF");
File newCertFolder = new File(getProjectPath() + File.separator
+ "META-INF");
rsaFile.renameTo(new File(getProjectPath() + File.separator
+ "META-INF" + File.separator + certificateName + ".RSA"));
sfFile.renameTo(new File(getProjectPath() + File.separator
+ "META-INF" + File.separator + certificateName + ".SF"));
ZipParameters parameters = new ZipParameters();
parameters.setCompressionMethod(Zip4jConstants.COMP_DEFLATE);
parameters.setCompressionLevel(Zip4jConstants.DEFLATE_LEVEL_NORMAL);
zipFile.addFolder(newCertFolder, parameters);
} catch (ZipException e) {
e.printStackTrace();
}
}
示例8: verifyBackupFile
import net.lingala.zip4j.exception.ZipException; //導入方法依賴的package包/類
public static boolean verifyBackupFile(File file) {
try {
ZipFile zipFile = new ZipFile(file);
FileHeader preferences = zipFile.getFileHeader(BACKUP_PREFERENCES_PATH);
FileHeader notificationRules = zipFile.getFileHeader(BACKUP_NOTIFICATION_RULES_PATH);
FileHeader commandAliases = zipFile.getFileHeader(BACKUP_COMMAND_ALIASES_PATH);
return preferences != null && notificationRules != null && commandAliases != null;
} catch (ZipException e) {
e.printStackTrace();
return false;
}
}
示例9: isBackupPasswordProtected
import net.lingala.zip4j.exception.ZipException; //導入方法依賴的package包/類
public static boolean isBackupPasswordProtected(File file) {
try {
ZipFile zipFile = new ZipFile(file);
FileHeader preferences = zipFile.getFileHeader(BACKUP_PREFERENCES_PATH);
return preferences.isEncrypted();
} catch (ZipException e) {
e.printStackTrace();
return false;
}
}
示例10: zip
import net.lingala.zip4j.exception.ZipException; //導入方法依賴的package包/類
/**
* 使用給定密碼壓縮指定文件或文件夾到指定位置.
* <p>
* dest可傳最終壓縮文件存放的絕對路徑,也可以傳存放目錄,也可以傳null或者"".<br />
* 如果傳null或者""則將壓縮文件存放在當前目錄,即跟源文件同目錄,壓縮文件名取源文件名,以.zip為後綴;<br />
* 如果以路徑分隔符(File.separator)結尾,則視為目錄,壓縮文件名取源文件名,以.zip為後綴,否則視為文件名.
* @param src 要壓縮的文件或文件夾路徑
* @param dest 壓縮文件存放路徑
* @param isCreateDir 是否在壓縮文件裏創建目錄,僅在壓縮文件為目錄時有效.<br />
* 如果為false,將直接壓縮目錄下文件到壓縮文件.
* @param passwd 壓縮使用的密碼
* @return 最終的壓縮文件存放的絕對路徑,如果為null則說明壓縮失敗.
*/
public static String zip(String src, String dest, boolean isCreateDir, String passwd) {
File srcFile = new File(src);
dest = buildDestinationZipFilePath(srcFile, dest);
ZipParameters parameters = new ZipParameters();
parameters.setCompressionMethod(Zip4jConstants.COMP_DEFLATE); // 壓縮方式
parameters.setCompressionLevel(Zip4jConstants.DEFLATE_LEVEL_NORMAL); // 壓縮級別
if (!StringUtils.isEmpty(passwd)) {
parameters.setEncryptFiles(true);
parameters.setEncryptionMethod(Zip4jConstants.ENC_METHOD_STANDARD); // 加密方式
parameters.setPassword(passwd.toCharArray());
}
try {
ZipFile zipFile = new ZipFile(dest);
if (srcFile.isDirectory()) {
// 如果不創建目錄的話,將直接把給定目錄下的文件壓縮到壓縮文件,即沒有目錄結構
if (!isCreateDir) {
File [] subFiles = srcFile.listFiles();
ArrayList<File> temp = new ArrayList<File>();
Collections.addAll(temp, subFiles);
zipFile.addFiles(temp, parameters);
return dest;
}
zipFile.addFolder(srcFile, parameters);
} else {
zipFile.addFile(srcFile, parameters);
}
return dest;
} catch (ZipException e) {
e.printStackTrace();
}
return null;
}
示例11: getInputStream
import net.lingala.zip4j.exception.ZipException; //導入方法依賴的package包/類
public static ZipInputStream getInputStream(File source, String fileName) {
try {
ZipFile zipFile = new ZipFile(source);
return zipFile.getInputStream(zipFile.getFileHeader(fileName));
} catch (ZipException e) {
e.printStackTrace();
}
return null;
}
示例12: installProject
import net.lingala.zip4j.exception.ZipException; //導入方法依賴的package包/類
public static boolean installProject(Context c, String from, String to) {
try {
FileIO.unZipFile(from, to);
return true;
} catch (ZipException e) {
e.printStackTrace();
}
return false;
}
示例13: unZipIt
import net.lingala.zip4j.exception.ZipException; //導入方法依賴的package包/類
public void unZipIt(String zipFileName, String outputFolder) {
try {
ZipFile zipFile = new ZipFile(zipFileName);
zipFile.extractAll(outputFolder);
} catch (ZipException e) {
e.printStackTrace();
}
}
示例14: hasFile
import net.lingala.zip4j.exception.ZipException; //導入方法依賴的package包/類
/**
* 是否包含指定文件
*
* @param zipFile
* @param fileName
* @return
*/
public static boolean hasFile(File zipFile, String fileName){
try {
if(!FileHelper.exists(zipFile)){
return false;
}
return hasFile(new ZipFile(zipFile),fileName);
} catch (ZipException e) {
e.printStackTrace();
}
return false;
}
示例15: decompressFile
import net.lingala.zip4j.exception.ZipException; //導入方法依賴的package包/類
public static void decompressFile(String zipfile, String dir, boolean erase) {
try {
ZipFile zipFile = new ZipFile(zipfile);
zipFile.extractAll(dir);
if (erase) {
org.apache.commons.io.FileUtils.deleteQuietly(new File(zipfile));
}
} catch (ZipException e) {
e.printStackTrace();
}
}