gpt4 book ai didi

net.lingala.zip4j.model.ZipParameters.getCompressionMethod()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-15 17:04:40 28 4
gpt4 key购买 nike

本文整理了Java中net.lingala.zip4j.model.ZipParameters.getCompressionMethod()方法的一些代码示例,展示了ZipParameters.getCompressionMethod()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZipParameters.getCompressionMethod()方法的具体详情如下:
包路径:net.lingala.zip4j.model.ZipParameters
类名称:ZipParameters
方法名:getCompressionMethod

ZipParameters.getCompressionMethod介绍

暂无

代码示例

代码示例来源:origin: net.lingala.zip4j/zip4j

public void closeEntry() throws IOException, ZipException {
  if (zipParameters.getCompressionMethod() == Zip4jConstants.COMP_DEFLATE) {
    if (!deflater.finished()) {
      deflater.finish();
      while (!deflater.finished()) {
        deflate();
      }
    }
    firstBytesRead = false;
  }
  super.closeEntry();
}

代码示例来源:origin: com.github.axet/zip4j

public void closeEntry() throws IOException, ZipException {
  if (zipParameters.getCompressionMethod() == Zip4jConstants.COMP_DEFLATE) {
    if (!deflater.finished()) {
      deflater.finish();
      while (!deflater.finished()) {
        deflate();
      }
    }
    firstBytesRead = false;
  }
  super.closeEntry();
}

代码示例来源: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: net.lingala.zip4j/zip4j

public void write(byte[] buf, int off, int len) throws IOException {
  if (zipParameters.getCompressionMethod() != Zip4jConstants.COMP_DEFLATE) {
    super.write(buf, off, len);
  } else {
    deflater.setInput(buf, off, len);
     while (!deflater.needsInput()) {
       deflate();
     }
  }        
}

代码示例来源:origin: com.github.axet/zip4j

public void write(byte[] buf, int off, int len) throws IOException {
  if (zipParameters.getCompressionMethod() != Zip4jConstants.COMP_DEFLATE) {
    super.write(buf, off, len);
  } else {
    deflater.setInput(buf, off, len);
     while (!deflater.needsInput()) {
       deflate();
     }
  }        
}

代码示例来源:origin: net.lingala.zip4j/zip4j

public void putNextEntry(File file, ZipParameters zipParameters)
    throws ZipException {
  super.putNextEntry(file, zipParameters);
  if (zipParameters.getCompressionMethod() == Zip4jConstants.COMP_DEFLATE) {
    deflater.reset();
    if ((zipParameters.getCompressionLevel() < 0 || zipParameters
        .getCompressionLevel() > 9)
        && zipParameters.getCompressionLevel() != -1) {
      throw new ZipException(
          "invalid compression level for deflater. compression level should be in the range of 0-9");
    }
    deflater.setLevel(zipParameters.getCompressionLevel());
  }
}

代码示例来源:origin: com.github.axet/zip4j

public void putNextEntry(NativeStorage file, ZipParameters zipParameters)
    throws ZipException {
  super.putNextEntry(file, zipParameters);
  if (zipParameters.getCompressionMethod() == Zip4jConstants.COMP_DEFLATE) {
    deflater.reset();
    if ((zipParameters.getCompressionLevel() < 0 || zipParameters
        .getCompressionLevel() > 9)
        && zipParameters.getCompressionLevel() != -1) {
      throw new ZipException(
          "invalid compression level for deflater. compression level should be in the range of 0-9");
    }
    deflater.setLevel(zipParameters.getCompressionLevel());
  }
}

代码示例来源: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");

代码示例来源: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");

代码示例来源:origin: net.lingala.zip4j/zip4j

private AESExtraDataRecord generateAESExtraDataRecord(ZipParameters parameters) throws ZipException {
  
  if (parameters == null) {
    throw new ZipException("zip parameters are null, cannot generate AES Extra Data record");
  }
  
  AESExtraDataRecord aesDataRecord = new AESExtraDataRecord();
  aesDataRecord.setSignature(InternalZipConstants.AESSIG);
  aesDataRecord.setDataSize(7);
  aesDataRecord.setVendorID("AE");
  // Always set the version number to 2 as we do not store CRC for any AES encrypted files
  // only MAC is stored and as per the specification, if version number is 2, then MAC is read
  // and CRC is ignored
  aesDataRecord.setVersionNumber(2); 
  if (parameters.getAesKeyStrength() == Zip4jConstants.AES_STRENGTH_128) {
    aesDataRecord.setAesStrength(Zip4jConstants.AES_STRENGTH_128);
  } else if (parameters.getAesKeyStrength() == Zip4jConstants.AES_STRENGTH_256) {
    aesDataRecord.setAesStrength(Zip4jConstants.AES_STRENGTH_256);
  } else {
    throw new ZipException("invalid AES key strength, cannot generate AES Extra data record");
  }
  aesDataRecord.setCompressionMethod(parameters.getCompressionMethod());
  
  return aesDataRecord;
}

代码示例来源:origin: com.github.axet/zip4j

private AESExtraDataRecord generateAESExtraDataRecord(ZipParameters parameters) throws ZipException {
  
  if (parameters == null) {
    throw new ZipException("zip parameters are null, cannot generate AES Extra Data record");
  }
  
  AESExtraDataRecord aesDataRecord = new AESExtraDataRecord();
  aesDataRecord.setSignature(InternalZipConstants.AESSIG);
  aesDataRecord.setDataSize(7);
  aesDataRecord.setVendorID("AE");
  // Always set the version number to 2 as we do not store CRC for any AES encrypted files
  // only MAC is stored and as per the specification, if version number is 2, then MAC is read
  // and CRC is ignored
  aesDataRecord.setVersionNumber(2); 
  if (parameters.getAesKeyStrength() == Zip4jConstants.AES_STRENGTH_128) {
    aesDataRecord.setAesStrength(Zip4jConstants.AES_STRENGTH_128);
  } else if (parameters.getAesKeyStrength() == Zip4jConstants.AES_STRENGTH_256) {
    aesDataRecord.setAesStrength(Zip4jConstants.AES_STRENGTH_256);
  } else {
    throw new ZipException("invalid AES key strength, cannot generate AES Extra data record");
  }
  aesDataRecord.setCompressionMethod(parameters.getCompressionMethod());
  
  return aesDataRecord;
}

代码示例来源:origin: net.lingala.zip4j/zip4j

fileHeader.setAesExtraDataRecord(generateAESExtraDataRecord(zipParameters));
} else {
  fileHeader.setCompressionMethod(zipParameters.getCompressionMethod());
  if (!zipParameters.isSourceExternalStream()) {
    long fileSize = Zip4jUtil.getFileLengh(sourceFile);
    if (zipParameters.getCompressionMethod() == Zip4jConstants.COMP_STORE) {
      if (zipParameters.getEncryptionMethod() == Zip4jConstants.ENC_METHOD_STANDARD) {
        fileHeader.setCompressedSize(fileSize
    fileHeader.isEncrypted(), zipParameters.getCompressionMethod()));
boolean isFileNameCharsetSet = Zip4jUtil.isStringNotNullAndNotEmpty(zipModel.getFileNameCharset());
if ((isFileNameCharsetSet &&

代码示例来源:origin: com.github.axet/zip4j

fileHeader.setAesExtraDataRecord(generateAESExtraDataRecord(zipParameters));
} else {
  fileHeader.setCompressionMethod(zipParameters.getCompressionMethod());
  if (!zipParameters.isSourceExternalStream()) {
    long fileSize = Zip4jUtil.getFileLengh(sourceFile);
    if (zipParameters.getCompressionMethod() == Zip4jConstants.COMP_STORE) {
      if (zipParameters.getEncryptionMethod() == Zip4jConstants.ENC_METHOD_STANDARD) {
        fileHeader.setCompressedSize(fileSize
    fileHeader.isEncrypted(), zipParameters.getCompressionMethod()));
boolean isFileNameCharsetSet = Zip4jUtil.isStringNotNullAndNotEmpty(zipModel.getFileNameCharset());
if ((isFileNameCharsetSet &&

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com