- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中net.lingala.zip4j.model.ZipParameters
类的一些代码示例,展示了ZipParameters
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZipParameters
类的具体详情如下:
包路径:net.lingala.zip4j.model.ZipParameters
类名称:ZipParameters
暂无
代码示例来源:origin: stackoverflow.com
ZipParameters parameters = new ZipParameters();
parameters.setCompressionMethod(Zip4jConstants.COMP_DEFLATE); // set compression method to deflate compression
//DEFLATE_LEVEL_FASTEST - Lowest compression level but higher speed of compression
//DEFLATE_LEVEL_FAST - Low compression level but higher speed of compression
//DEFLATE_LEVEL_NORMAL - Optimal balance between compression level/speed
//DEFLATE_LEVEL_MAXIMUM - High compression level with a compromise of speed
//DEFLATE_LEVEL_ULTRA - Highest compression level but low speed
parameters.setCompressionLevel(Zip4jConstants.DEFLATE_LEVEL_NORMAL);
//Set the encryption flag to true
parameters.setEncryptFiles(true);
//Set the encryption method to AES Zip Encryption
parameters.setEncryptionMethod(Zip4jConstants.ENC_METHOD_AES);
//AES_STRENGTH_128 - For both encryption and decryption
//AES_STRENGTH_192 - For decryption only
//AES_STRENGTH_256 - For both encryption and decryption
//Key strength 192 cannot be used for encryption. But if a zip file already has a
//file encrypted with key strength of 192, then Zip4j can decrypt this file
parameters.setAesKeyStrength(Zip4jConstants.AES_STRENGTH_256);
代码示例来源:origin: net.lingala.zip4j/zip4j
/**
* Sets the password for the zip file or the file being added<br>
* <b>Note</b>: For security reasons, usage of this method is discouraged. Use
* setPassword(char[]) instead. As strings are immutable, they cannot be wiped
* out from memory explicitly after usage. Therefore, usage of Strings to store
* passwords is discouraged. More info here:
* http://docs.oracle.com/javase/1.5.0/docs/guide/security/jce/JCERefGuide.html#PBEEx
* @param password
*/
public void setPassword(String password) {
if (password == null) return;
setPassword(password.toCharArray());
}
代码示例来源:origin: stackoverflow.com
public void EmployeeEncyrptedZipFileDownload(HttpServletResponse response, @RequestParam(value = "id", required = true) int employeeId) throws IOException, ZipException
{
//Prepare text file contents
String fileContent = "Hallo Welt";
response.setContentType("application/zip");
response.setHeader("Content-Disposition", "attachment;filename=test.zip");
final StringBuilder sb = new StringBuilder(fileContent);
final ZipOutputStream zout = new ZipOutputStream(response.getOutputStream());
ZipParameters zipParameters = new ZipParameters();
zipParameters.setSourceExternalStream(true);
zipParameters.setFileNameInZip("mytext.txt");
zout.putNextEntry(null, zipParameters);
byte[] data = sb.toString().getBytes();
zout.write(data, 0, data.length);
zout.closeEntry();
zout.finish();
}
代码示例来源:origin: stackoverflow.com
net.lingala.zip4j.core.ZipFile zipFile = new ZipFile("out.zip");
ZipParameters parameters = new ZipParameters();
parameters.setCompressionMethod(Zip4jConstants.COMP_DEFLATE);
parameters.setCompressionLevel(Zip4jConstants.DEFLATE_LEVEL_NORMAL);
zipFile.createZipFileFromFolder("path/to/source/dir", parameters, true, maximum size);
代码示例来源:origin: stackoverflow.com
ZipParameters zp = new ZipParameters();
zp.setFileNameInZip("sample.zip");
System.out.println(zp.getCompressionMethod());
System.out.println(Zip4jConstants.COMP_DEFLATE);
OutPut:
8
8
代码示例来源:origin: stackoverflow.com
ZipParameters zipParams = new ZipParameters();
zipParams.setCompressionMethod(Zip4jConstants.COMP_DEFLATE);
zipParams.setCompressionLevel(Zip4jConstants.DEFLATE_LEVEL_NORMAL);
zipParams.setEncryptFiles(true);
zipParams.setEncryptionMethod(Zip4jConstants.ENC_METHOD_STANDARD);
zipParams.setPassword(pass);
zipParams.setSourceExternalStream(true);
zipParams.setFileNameInZip(fileName);
代码示例来源:origin: net.lingala.zip4j/zip4j
public void putNextEntry(File file, ZipParameters zipParameters) throws ZipException {
if (!zipParameters.isSourceExternalStream() && file == null) {
throw new ZipException("input file is null");
if (!zipParameters.isSourceExternalStream() && !Zip4jUtil.checkFileExists(file)) {
throw new ZipException("input file does not exist");
this.zipParameters = (ZipParameters)zipParameters.clone();
if (!zipParameters.isSourceExternalStream()) {
if (sourceFile.isDirectory()) {
this.zipParameters.setEncryptFiles(false);
this.zipParameters.setEncryptionMethod(-1);
this.zipParameters.setCompressionMethod(Zip4jConstants.COMP_STORE);
if (!Zip4jUtil.isStringNotNullAndNotEmpty(this.zipParameters.getFileNameInZip())) {
throw new ZipException("file name is empty for external stream");
if (this.zipParameters.getFileNameInZip().endsWith("/") ||
this.zipParameters.getFileNameInZip().endsWith("\\")) {
this.zipParameters.setEncryptFiles(false);
this.zipParameters.setEncryptionMethod(-1);
this.zipParameters.setCompressionMethod(Zip4jConstants.COMP_STORE);
if (this.zipParameters.isEncryptFiles()) {
initEncrypter();
if (encrypter != null) {
if (zipParameters.getEncryptionMethod() == Zip4jConstants.ENC_METHOD_STANDARD) {
byte[] headerBytes = ((StandardEncrypter)encrypter).getHeaderBytes();
outputStream.write(headerBytes);
代码示例来源:origin: stackoverflow.com
long _start = System.currentTimeMillis();
ZipFile _zipFile = new ZipFile(System.nanoTime()+".zip");
ZipParameters _parameters = new ZipParameters();
_parameters.setCompressionMethod(Zip4jConstants.COMP_STORE);
_parameters.setCompressionLevel(Zip4jConstants.DEFLATE_LEVEL_FASTEST);
_parameters.setIncludeRootFolder(false);
ArrayList<File> _files = new ArrayList<File>();
for(int j=1;j<5;j++){
long start = System.currentTimeMillis();
ZipFile zipFile = new ZipFile(System.nanoTime()+".zip");
ZipParameters parameters = new ZipParameters();
parameters.setCompressionMethod(Zip4jConstants.COMP_STORE);
parameters.setCompressionLevel(Zip4jConstants.DEFLATE_LEVEL_FASTEST);
parameters.setIncludeRootFolder(false);
ArrayList<File> files = new ArrayList<File>();
for(int j=1;j<5;j++){
代码示例来源:origin: stackoverflow.com
ZipParameters parameters = new ZipParameters();
parameters.setIncludeRootFolder(true);
zipFile.removeFile(fh);
zipFile.addFolder(new File(tempdir.toFile(), "META-INF"), parameters);
代码示例来源:origin: net.lingala.zip4j/zip4j
if ((parameters.getCompressionMethod() != Zip4jConstants.COMP_STORE) &&
parameters.getCompressionMethod() != Zip4jConstants.COMP_DEFLATE) {
throw new ZipException("unsupported compression type");
if (parameters.getCompressionMethod() == Zip4jConstants.COMP_DEFLATE) {
if (parameters.getCompressionLevel() < 0 && parameters.getCompressionLevel() > 9) {
throw new ZipException("invalid compression level. compression level dor deflate should be in the range of 0-9");
if (parameters.isEncryptFiles()) {
if (parameters.getEncryptionMethod() != Zip4jConstants.ENC_METHOD_STANDARD &&
parameters.getEncryptionMethod() != Zip4jConstants.ENC_METHOD_AES) {
throw new ZipException("unsupported encryption method");
if (parameters.getPassword() == null || parameters.getPassword().length <= 0) {
throw new ZipException("input password is empty or null");
parameters.setAesKeyStrength(-1);
parameters.setEncryptionMethod(-1);
代码示例来源:origin: dwatling/apk-decompiler
private void generateZipFile() {
try {
File outputFile = new File(this.workFolder.getName() + ".zip");
if (outputFile.exists()) {
Logger.info(outputFile.getAbsolutePath() + " already exists. Deleting.");
outputFile.delete();
}
ZipFile output = new net.lingala.zip4j.core.ZipFile(outputFile);
Logger.info("Generating " + output.getFile().getAbsolutePath());
ZipParameters params = new ZipParameters();
params.setIncludeRootFolder(false);
params.setRootFolderInZip("");
output.addFolder(this.workFolder.getAbsolutePath() + File.separator + "apktool", params);
params.setRootFolderInZip("classes");
output.addFolder(this.workFolder.getAbsolutePath() + File.separator + "classes", params);
} catch (Throwable t) {
Logger.error("Unable to generate final zip file.", t);
}
}
代码示例来源:origin: net.lingala.zip4j/zip4j
ZipParameters fileParameters = (ZipParameters) parameters.clone();
if (fileParameters.isEncryptFiles() && fileParameters.getEncryptionMethod() == Zip4jConstants.ENC_METHOD_STANDARD) {
progressMonitor.setCurrentOperation(ProgressMonitor.OPERATION_CALC_CRC);
fileParameters.setSourceFileCRC((int)CRCUtil.computeFileCRC(((File)fileList.get(i)).getAbsolutePath(), progressMonitor));
progressMonitor.setCurrentOperation(ProgressMonitor.OPERATION_ADD);
fileParameters.setCompressionMethod(Zip4jConstants.COMP_STORE);
代码示例来源:origin: org.jboss.forge.addon/resources-impl
ZipParameters parameters = new ZipParameters();
for (File directory : directories)
代码示例来源:origin: com.tomitribe.tribestream/tribestream-container
public byte[] createZip(final ZipContent content,
final String password) {
final ZipParameters parameters = new ZipParameters();
parameters.setEncryptFiles(true);
parameters.setPassword(password);
parameters.setEncryptionMethod(Zip4jConstants.ENC_METHOD_STANDARD); // AES is good but poorly supported by zip UIs
parameters.setCompressionMethod(Zip4jConstants.COMP_DEFLATE);
parameters.setCompressionLevel(Zip4jConstants.DEFLATE_LEVEL_NORMAL);
if (content.files != null) {
for (final File f : content.files) {
parameters.setFileNameInZip(f.getName()); // drop the name
zip.addFile(f, parameters);
for (final FileContent c : content.contents) {
try (final InputStream stream = new ByteArrayInputStream(c.content)) {
parameters.setSourceExternalStream(true);
parameters.setFileNameInZip(c.name);
zip.addStream(stream, parameters);
} catch (final IOException e) { // more than unlikely
代码示例来源:origin: stackoverflow.com
ZipFile zipfile = new ZipFile("/mnt/sdcard/bla.zip");
ZipParameters parameters = new ZipParameters();
parameters.setCompressionMethod(Zip4jConstants.COMP_DEFLATE);
parameters.setCompressionLevel(Zip4jConstants.DEFLATE_LEVEL_NORMAL);
zipfile.addFolder("/mnt/sdcard/folderToZip", parameters);
代码示例来源:origin: com.github.axet/zip4j
public void putNextEntry(NativeStorage file, ZipParameters zipParameters) throws ZipException {
if (!zipParameters.isSourceExternalStream() && file == null) {
throw new ZipException("input file is null");
if (!zipParameters.isSourceExternalStream() && !Zip4jUtil.checkFileExists(file)) {
throw new ZipException("input file does not exist");
this.zipParameters = (ZipParameters)zipParameters.clone();
if (!zipParameters.isSourceExternalStream()) {
if (sourceFile.isDirectory()) {
this.zipParameters.setEncryptFiles(false);
this.zipParameters.setEncryptionMethod(-1);
this.zipParameters.setCompressionMethod(Zip4jConstants.COMP_STORE);
if (!Zip4jUtil.isStringNotNullAndNotEmpty(this.zipParameters.getFileNameInZip())) {
throw new ZipException("file name is empty for external stream");
if (this.zipParameters.getFileNameInZip().endsWith("/") ||
this.zipParameters.getFileNameInZip().endsWith("\\")) {
this.zipParameters.setEncryptFiles(false);
this.zipParameters.setEncryptionMethod(-1);
this.zipParameters.setCompressionMethod(Zip4jConstants.COMP_STORE);
if (this.zipParameters.isEncryptFiles()) {
initEncrypter();
if (encrypter != null) {
if (zipParameters.getEncryptionMethod() == Zip4jConstants.ENC_METHOD_STANDARD) {
byte[] headerBytes = ((StandardEncrypter)encrypter).getHeaderBytes();
outputStream.write(headerBytes);
代码示例来源:origin: org.apache.apex/apex-engine
public static void createAppPackageFile(File fileToBeCreated, File directory) throws ZipException
{
ZipFile zipFile = new ZipFile(fileToBeCreated);
ZipParameters params = new ZipParameters();
params.setIncludeRootFolder(false);
zipFile.addFolder(directory, params);
}
代码示例来源:origin: com.github.axet/zip4j
if ((parameters.getCompressionMethod() != Zip4jConstants.COMP_STORE) &&
parameters.getCompressionMethod() != Zip4jConstants.COMP_DEFLATE) {
throw new ZipException("unsupported compression type");
if (parameters.getCompressionMethod() == Zip4jConstants.COMP_DEFLATE) {
if (parameters.getCompressionLevel() < 0 && parameters.getCompressionLevel() > 9) {
throw new ZipException("invalid compression level. compression level dor deflate should be in the range of 0-9");
if (parameters.isEncryptFiles()) {
if (parameters.getEncryptionMethod() != Zip4jConstants.ENC_METHOD_STANDARD &&
parameters.getEncryptionMethod() != Zip4jConstants.ENC_METHOD_AES) {
throw new ZipException("unsupported encryption method");
if (parameters.getPassword() == null || parameters.getPassword().length <= 0) {
throw new ZipException("input password is empty or null");
parameters.setAesKeyStrength(-1);
parameters.setEncryptionMethod(-1);
代码示例来源:origin: com.github.axet/zip4j
ZipParameters fileParameters = (ZipParameters) parameters.clone();
if (fileParameters.isEncryptFiles() && fileParameters.getEncryptionMethod() == Zip4jConstants.ENC_METHOD_STANDARD) {
progressMonitor.setCurrentOperation(ProgressMonitor.OPERATION_CALC_CRC);
fileParameters.setSourceFileCRC((int)CRCUtil.computeFileCRC((NativeStorage)fileList.get(i), progressMonitor));
progressMonitor.setCurrentOperation(ProgressMonitor.OPERATION_ADD);
fileParameters.setCompressionMethod(Zip4jConstants.COMP_STORE);
代码示例来源:origin: org.openmrs.maven.plugins/openmrs-sdk-maven-plugin
downloadOWAs(targetDirectory, distroProperties, owasDir);
warfile.addFolder(tempDir, new ZipParameters());
try {
FileUtils.deleteDirectory(tempDir);
在C语言中,当有变量(假设都是int)i小于j时,我们可以用等式 i^=j^=i^=j 交换两个变量的值。例如,令int i = 3,j = 5;在计算 i^=j^=i^=j 之后,我有 i = 5,
我为以下问题编写了以下代码: 给定一个由 N 个正整数组成的序列 A,编写一个程序来查找满足 i > A[j]A[i](A[i] 的 A[j] 次方 > A[j] 的 A[i] 次方)。 我的代码通过
这个表达式是从左到右解析的吗?我试图解释解析的结果,但最后的结果是错误的。 int j=10, k=10; j+=j-=j*=j; //j=j+(j-=j*=j)=j+(j-j*j) k+=k*=
给定一个整数数组 A ,我试图找出在给定位置 j ,A[j] 从每个 i=0 到 i=j 在 A 中出现了多少次。我设计了一个如下所示的解决方案 map CF[400005]; for(int i=0
你能帮我算法吗: 给定 2 个相同大小的数组 a[]和 b[]具有大于或等于 1 的整数。 查找不相等的索引 i和 j ( i != j ) 使得值 -max(a[i]*b[i] + a[i] * b
每次用J的M.副词,性能显着下降。因为我怀疑艾弗森和许比我聪明得多,我一定是做错了什么。 考虑 Collatz conjecture .这里似乎有各种各样的内存机会,但不管我放在哪里M. ,性能太差了
假设一个包含各种类型的盒装矩阵: matrix =: ('abc';'defgh';23),:('foo';'bar';45) matrix +---+-----+--+|abc|defgh|23|+
是否有可能对于两个正整数 i 和 j,(-i)/j 不等于 -(i/j)?我不知道这是否可能......我认为这将是关于位的东西,或者 char 类型的溢出或其他东西,但我找不到它。有什么想法吗? 最
假设两个不同大小的数组: N0 =: i. 50 N1 =: i. 500 应该有一种方法可以获得唯一的对,只需将两者结合起来即可。我发现的“最简单”是: ]$R =: |:,"2 |: (,.N0)
我是 J 的新用户,我只是想知道 J 包中是否实现了三次样条插值方法? 最佳答案 我自己不熟悉,但是我确实安装了所有的包,所以 $ rg -l -i spline /usr/share/j/9.02
在 Q/kdb 中,您可以使用 ': 轻松修改动词,它代表每个优先级。它会将动词应用于一个元素及其之前的邻居。例如 =': 检查值对是否相等。在 J 中,您可以轻松折叠 /\ 但它是累积的,是否有成对
嗨,我有一个 4x4 双矩阵 A 1+2i 2-1i -3-2i -1+4i 3-1i -3+2i 1-3i -1-3i 4+3i 3+5i 1-2i -1-4i
刚刚发现 J 语言,我输入: 1+^o.*0j1 I expected the answer to be 0 ,但我得到了 0j1.22465e_16。虽然这非常接近于 0,但我想知道为什么 J 应该
这个问题在这里已经有了答案: With arrays, why is it the case that a[5] == 5[a]? (20 个答案) 关闭 3 年前。 我正在阅读“C++ 编程语言”
当第一行是 1, 1/2 , 1/3 ....这是支持该问题的图像。 是否存在比朴素的 O(n^2) 方法更有效的方法? 我在研究伯努利数时遇到了这个问题,然后在研究“Akiyama-Tanigawa
我写了一段Java代码,它在无限循环中运行。 下面是代码: public class TestProgram { public static void main(String[] args){
for (int i = n; i > 0; i /= 2) { for (int j = 0; j 0; i /= 2) 的第一个循环结果 O(log N) . 第二个循环for (int
如问题中所述,需要找到数组中 (i,j) 对的总数,使得 (1) **ia[j]** 其中 i 和 j 是数组的索引。没有空间限制。 我的问题是 1) Is there any approach w
for l in range(1,len(S)-1): for i in range(1,len(S)-l): j=i+l for X in N:
第二个for循环的复杂度是多少?会是n-i吗?根据我的理解,第一个 for 循环将执行 n 次,但第二个 for 循环中的索引设置为 i。 //where n is the number elemen
我是一名优秀的程序员,十分优秀!