gpt4 book ai didi

net.lingala.zip4j.util.Zip4jUtil类的使用及代码示例

转载 作者:知者 更新时间:2024-03-13 10:03:58 31 4
gpt4 key购买 nike

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

Zip4jUtil介绍

暂无

代码示例

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

boolean splitArchive, long splitLength) throws ZipException {
if (!Zip4jUtil.isStringNotNullAndNotEmpty(file)) {
  throw new ZipException("zip file path is empty");
if (Zip4jUtil.checkFileExists(file)) {
  throw new ZipException("zip file: " + file + " already exists. To add files to existing zip file use addFile method");
if (!Zip4jUtil.checkArrayListTypes(sourceFileList, InternalZipConstants.LIST_TYPE_FILE)) {
  throw new ZipException("One or more elements in the input ArrayList is not of type File");

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

if (!Zip4jUtil.checkFileExists(file.getAbsolutePath())) {
  throw new ZipException("input folder does not exist");
if (!Zip4jUtil.checkFileReadAccess(file.getAbsolutePath())) {
  throw new ZipException("cannot read folder: " + file.getAbsolutePath());
ArrayList fileList = Zip4jUtil.getFilesInDirectoryRec(file, parameters.isReadHiddenFiles());

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

/**
 * returns the length of the string by wrapping it in a byte buffer with
 * the appropriate charset of the input string and returns the limit of the 
 * byte buffer
 * @param str
 * @return length of the string
 * @throws ZipException
 */
public static int getEncodedStringLength(String str) throws ZipException {
  if (!isStringNotNullAndNotEmpty(str)) {
    throw new ZipException("input string is null, cannot calculate encoded String length");
  }
  
  String charset = detectCharSet(str);
  return getEncodedStringLength(str, charset);
}

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

public static boolean checkFileExists(String path) throws ZipException {
  if (!isStringNotNullAndNotEmpty(path)) {
    throw new ZipException("path is null");
  }
  
  File file = new File(path);
  return checkFileExists(file);
}

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

fileHeader.setLastModFileTime((int) Zip4jUtil.javaToDosTime(System.currentTimeMillis()));
  if (!Zip4jUtil.isStringNotNullAndNotEmpty(zipParameters.getFileNameInZip())) {
    throw new ZipException("fileNameInZip is null or empty");
  fileHeader.setLastModFileTime((int) Zip4jUtil.javaToDosTime((Zip4jUtil.getLastModifiedFileTime(
      sourceFile, zipParameters.getTimeZone()))));
  fileHeader.setUncompressedSize(sourceFile.length());
  fileName = Zip4jUtil.getRelativeFileName(
      sourceFile.getAbsolutePath(), zipParameters.getRootFolderInZip(), zipParameters.getDefaultFolderPath());
if (!Zip4jUtil.isStringNotNullAndNotEmpty(fileName)) {
  throw new ZipException("fileName is null or empty. unable to create file header");
if (Zip4jUtil.isStringNotNullAndNotEmpty(zipModel.getFileNameCharset())) {
  fileHeader.setFileNameLength(Zip4jUtil.getEncodedStringLength(fileName, 
      zipModel.getFileNameCharset()));
} else {
  fileHeader.setFileNameLength(Zip4jUtil.getEncodedStringLength(fileName));
} else {
  if (!zipParameters.isSourceExternalStream()) {
    long fileSize = Zip4jUtil.getFileLengh(sourceFile);
    if (zipParameters.getCompressionMethod() == Zip4jConstants.COMP_STORE) {
      if (zipParameters.getEncryptionMethod() == Zip4jConstants.ENC_METHOD_STANDARD) {
shortByte[0] = Raw.bitArrayToByte(generateGeneralPurposeBitArray(
    fileHeader.isEncrypted(), zipParameters.getCompressionMethod()));
boolean isFileNameCharsetSet = Zip4jUtil.isStringNotNullAndNotEmpty(zipModel.getFileNameCharset());
if ((isFileNameCharsetSet &&

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

/**
 * Loads the zip model if zip model is null and if zip file exists.
 * @throws ZipException
 */
private void checkZipModel() throws ZipException {
  if (this.zipModel == null) {
    if (Zip4jUtil.checkFileExists(file)) {
      readZipInfo();
    } else {
      createNewZipModel();
    }
  }
}

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

if (!Zip4jUtil.isStringNotNullAndNotEmpty(fileName)) {
  throw new ZipException("file name is empty or null, cannot remove file");
  if (Zip4jUtil.checkFileExists(file)) {
    readZipInfo();
FileHeader fileHeader = Zip4jUtil.getFileHeader(zipModel, fileName);
if (fileHeader == null) {
  throw new ZipException("could not find file header for file: " + fileName);

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

sizeOfFileHeader += 4;
if (Zip4jUtil.isStringNotNullAndNotEmpty(zipModel.getFileNameCharset())) {
  byte[] fileNameBytes = fileHeader.getFileName().getBytes(zipModel.getFileNameCharset());
  copyByteArrayToArrayList(fileNameBytes,    headerBytesList);
  sizeOfFileHeader += fileNameBytes.length;
} else {
  copyByteArrayToArrayList(Zip4jUtil.convertCharset(fileHeader.getFileName()), headerBytesList);
  sizeOfFileHeader += Zip4jUtil.getEncodedStringLength(fileHeader.getFileName());

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

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");

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

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 (Zip4jUtil.checkFileExists(file)) {
  if (zipModel.isSplitArchive()) {
    throw new ZipException("Zip file already exists. Zip file format does not allow updating split/spanned files");

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

if (!Zip4jUtil.checkFileExists(file)) {
  throw new ZipException("zip file does not exist");
if (!Zip4jUtil.checkFileReadAccess(this.file)) {
  throw new ZipException("no read access for the input zip file");

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

if (Zip4jUtil.isSupportedCharset(InternalZipConstants.CHARSET_COMMENTS_DEFAULT)) {
    encoding = InternalZipConstants.CHARSET_COMMENTS_DEFAULT;
  } else {
if (Zip4jUtil.checkFileExists(file)) {
  checkZipModel();
} else {

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

if (!Zip4jUtil.isStringNotNullAndNotEmpty(inputFile)) {
  throw new ZipException("input file is null or empty, cannot calculate CRC for the file");
  Zip4jUtil.checkFileReadAccess(inputFile);

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

boolean isZipFileAlreadExists = Zip4jUtil.checkFileExists(zipModel.getZipFile());
    if (Zip4jUtil.getFileLengh((File)fileList.get(i)) == 0) {
      fileParameters.setCompressionMethod(Zip4jConstants.COMP_STORE);

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

if (Zip4jUtil.isStringNotNullAndNotEmpty(zipModel.getFileNameCharset())) {
  byte[] fileNameBytes = localFileHeader.getFileName().getBytes(zipModel.getFileNameCharset());
  copyByteArrayToArrayList(fileNameBytes,    byteArrayList);
} else {
  copyByteArrayToArrayList(Zip4jUtil.convertCharset(localFileHeader.getFileName()), byteArrayList);

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

if (Zip4jUtil.isStringNotNullAndNotEmpty(zipModel.getFileNameCharset())) {
  fileName = new String(fileNameBuf, zipModel.getFileNameCharset());
} else {
  fileName = Zip4jUtil.decodeFileName(fileNameBuf, fileHeader.isFileNameUTF8Encoded());

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

private static void setFileLastModifiedTime(FileHeader fileHeader, File file) throws ZipException {
  if (fileHeader.getLastModFileTime() <= 0) {
    return;
  }
  
  if (file.exists()) {
    file.setLastModified(Zip4jUtil.dosToJavaTme(fileHeader.getLastModFileTime()));
  }
}

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

private boolean isHeaderData(byte[] buff) {
  if (buff == null || buff.length < 4) {
    return false;
  }
  
  int signature = Raw.readIntLittleEndian(buff, 0);
  long[] allHeaderSignatures = Zip4jUtil.getAllHeaderSignatures();
  if (allHeaderSignatures != null && allHeaderSignatures.length > 0) {
    for (int i = 0; i < allHeaderSignatures.length; i++) {
      //Ignore split signature
      if (allHeaderSignatures[i] != InternalZipConstants.SPLITSIG && 
          allHeaderSignatures[i] == signature) {
        return true;
      }
    }
  }
  
  return false;
}

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

public static byte[] convertCharset(String str) throws ZipException {
  try {
    byte[] converted = null;
    String charSet = detectCharSet(str);
    if (charSet.equals(InternalZipConstants.CHARSET_CP850)) {
      converted = str.getBytes(InternalZipConstants.CHARSET_CP850);
    } else if (charSet.equals(InternalZipConstants.CHARSET_UTF8)) {
      converted = str.getBytes(InternalZipConstants.CHARSET_UTF8);
    } else {
      converted = str.getBytes();
    }
    return converted;
  }
  catch (UnsupportedEncodingException err) {
    return str.getBytes();
  } catch (Exception e) {
    throw new ZipException(e);
  }
}

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

/**
 * Extracts file to the specified directory using any 
 * user defined parameters in UnzipParameters. Output file name
 * will be overwritten with the value in newFileName. If this 
 * parameter is null, then file name will be the same as in 
 * FileHeader.getFileName
 * @param zipModel
 * @param outPath
 * @param unzipParameters
 * @throws ZipException
 */
public void extractFile(ZipModel zipModel, String outPath, 
    UnzipParameters unzipParameters, String newFileName, 
    ProgressMonitor progressMonitor, boolean runInThread) throws ZipException {
  if (zipModel == null) {
    throw new ZipException("input zipModel is null");
  }
  
  if (!Zip4jUtil.checkOutputFolder(outPath)) {
    throw new ZipException("Invalid output path");
  }
  
  if (this == null) {
    throw new ZipException("invalid file header");
  }
  Unzip unzip = new Unzip(zipModel);
  unzip.extractFile(this, outPath, unzipParameters, newFileName, progressMonitor, runInThread);
}

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