net.lingala.zip4j.util.Zip4jUtil.checkFileExists()方法的使用及代码示例

x33g5p2x  于2022-02-05 转载在 其他  
字(8.5k)|赞(0)|评价(0)|浏览(143)

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

Zip4jUtil.checkFileExists介绍

暂无

代码示例

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

/**
 * 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

/**
 * 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: net.lingala.zip4j/zip4j

public RandomAccessFile startNextSplitFile() throws IOException, FileNotFoundException {
  String currZipFile = zipModel.getZipFile();
  String partFile = null;
  if (currSplitFileCounter == zipModel.getEndCentralDirRecord().getNoOfThisDisk()) {
    partFile = zipModel.getZipFile();
  } else {
    if (currSplitFileCounter >= 9) {
      partFile = currZipFile.substring(0, currZipFile.lastIndexOf(".")) + ".z" + (currSplitFileCounter + 1);
    } else {
      partFile = currZipFile.substring(0, currZipFile.lastIndexOf(".")) + ".z0" + (currSplitFileCounter + 1);
    }
  }
  currSplitFileCounter++;
  try {
    if(!Zip4jUtil.checkFileExists(partFile)) {
      throw new IOException("zip split file does not exist: " + partFile);
    }
  } catch (ZipException e) {
    throw new IOException(e.getMessage());
  }
  return new RandomAccessFile(partFile, InternalZipConstants.READ_MODE);
}

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

public static boolean checkFileReadAccess(String path) throws ZipException {
  if (!isStringNotNullAndNotEmpty(path)) {
    throw new ZipException("path is null");
  }
  
  if (!checkFileExists(path)) {
    throw new ZipException("file does not exist: " + path);
  }
  
  try {
    File file = new File(path);
    return file.canRead();
  } catch (Exception e) {
    throw new ZipException("cannot read zip file");
  }
}

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

public static boolean checkFileWriteAccess(String path) throws ZipException {
  if (!isStringNotNullAndNotEmpty(path)) {
    throw new ZipException("path is null");
  }
  
  if (!checkFileExists(path)) {
    throw new ZipException("file does not exist: " + path);
  }
  
  try {
    File file = new File(path);
    return file.canWrite();
  } catch (Exception e) {
    throw new ZipException("cannot read zip file");
  }
}

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

public NativeFile startNextSplitFile() throws IOException, FileNotFoundException {
  NativeStorage currZipFile = zipModel.getZipFile();
  String currZipFileName = currZipFile.getName();
  NativeStorage partFile = null;
  if (currSplitFileCounter == zipModel.getEndCentralDirRecord().getNoOfThisDisk()) {
    partFile = zipModel.getZipFile();
  } else {
    if (currSplitFileCounter >= 9) {
      partFile = currZipFile.getParent().open(currZipFileName.substring(0, currZipFileName.lastIndexOf(".")) + ".z" + (currSplitFileCounter + 1));
    } else {
      partFile = currZipFile.getParent().open(currZipFileName.substring(0, currZipFileName.lastIndexOf(".")) + ".z0" + (currSplitFileCounter + 1));
    }
  }
  currSplitFileCounter++;
  try {
    if(!Zip4jUtil.checkFileExists(partFile)) {
      throw new IOException("zip split file does not exist: " + partFile);
    }
  } catch (ZipException e) {
    throw new IOException(e.getMessage());
  }
  return partFile.read();
}

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

public static boolean checkFileWriteAccess(NativeStorage path) throws ZipException {
  if (!isStringNotNullAndNotEmpty(path)) {
    throw new ZipException("path is null");
  }
  
  if (!checkFileExists(path)) {
    throw new ZipException("file does not exist: " + path);
  }
  
  try {
    return path.canWrite();
  } catch (Exception e) {
    throw new ZipException("cannot read zip file");
  }
}

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

public static boolean checkFileReadAccess(NativeStorage path) throws ZipException {
  if (!isStringNotNullAndNotEmpty(path)) {
    throw new ZipException("path is null");
  }
  
  if (!checkFileExists(path)) {
    throw new ZipException("file does not exist: " + path);
  }
  
  try {
    return path.canRead();
  } catch (Exception e) {
    throw new ZipException("cannot read zip file");
  }
}

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

/**
 * Removes the file provided in the input file header from the zip file.
 * If zip file is a split zip file, then this method throws an exception as
 * zip specification does not allow for updating split zip archives.
 * @param fileHeader
 * @throws ZipException
 */
public void removeFile(FileHeader fileHeader) throws ZipException {
  if (fileHeader == null) {
    throw new ZipException("file header is null, cannot remove file");
  }
  
  if (zipModel == null) {
    if (Zip4jUtil.checkFileExists(file)) {
      readZipInfo();
    }
  }
  
  if (zipModel.isSplitArchive()) {
    throw new ZipException("Zip file format does not allow updating split/spanned files");
  }
  
  ArchiveMaintainer archiveMaintainer = new ArchiveMaintainer();
  archiveMaintainer.initProgressMonitorForRemoveOp(zipModel, fileHeader, progressMonitor);
  archiveMaintainer.removeZipFile(zipModel, fileHeader, progressMonitor, runInThread);
}

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

/**
 * Removes the file provided in the input file header from the zip file.
 * If zip file is a split zip file, then this method throws an exception as
 * zip specification does not allow for updating split zip archives.
 * @param fileHeader
 * @throws ZipException
 */
public void removeFile(FileHeader fileHeader) throws ZipException {
  if (fileHeader == null) {
    throw new ZipException("file header is null, cannot remove file");
  }
  
  if (zipModel == null) {
    if (Zip4jUtil.checkFileExists(file)) {
      readZipInfo();
    }
  }
  
  if (zipModel.isSplitArchive()) {
    throw new ZipException("Zip file format does not allow updating split/spanned files");
  }
  
  ArchiveMaintainer archiveMaintainer = new ArchiveMaintainer();
  archiveMaintainer.initProgressMonitorForRemoveOp(zipModel, fileHeader, progressMonitor);
  archiveMaintainer.removeZipFile(zipModel, fileHeader, progressMonitor, runInThread);
}

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

/**
 * Sets comment for the Zip file
 * @param comment
 * @throws ZipException
 */
public void setComment(String comment) throws ZipException {
  if (comment == null) {
    throw new ZipException("input comment is null, cannot update zip file");
  }
  
  if (!Zip4jUtil.checkFileExists(file)) {
    throw new ZipException("zip file does not exist, cannot set comment for zip file");
  }
  
  readZipInfo();
  
  if (this.zipModel == null) {
    throw new ZipException("zipModel is null, cannot update zip file");
  }
  
  if (zipModel.getEndCentralDirRecord() == null) {
    throw new ZipException("end of central directory is null, cannot set comment");
  }
  
  ArchiveMaintainer archiveMaintainer = new ArchiveMaintainer();
  archiveMaintainer.setComment(zipModel, comment);
}

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

/**
 * Sets comment for the Zip file
 * @param comment
 * @throws ZipException
 */
public void setComment(String comment) throws ZipException {
  if (comment == null) {
    throw new ZipException("input comment is null, cannot update zip file");
  }
  
  if (!Zip4jUtil.checkFileExists(file)) {
    throw new ZipException("zip file does not exist, cannot set comment for zip file");
  }
  
  readZipInfo();
  
  if (this.zipModel == null) {
    throw new ZipException("zipModel is null, cannot update zip file");
  }
  
  if (zipModel.getEndCentralDirRecord() == null) {
    throw new ZipException("end of central directory is null, cannot set comment");
  }
  
  ArchiveMaintainer archiveMaintainer = new ArchiveMaintainer();
  archiveMaintainer.setComment(zipModel, comment);
}

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

if (Zip4jUtil.checkFileExists(file)) {
  readZipInfo();

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

if (Zip4jUtil.checkFileExists(file)) {
  readZipInfo();

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

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: com.github.axet/zip4j

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)) {
  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("cannot set file properties: file doesnot exist");

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

if (!Zip4jUtil.checkFileExists(file)) {
  throw new ZipException("cannot set file properties: file doesnot exist");

相关文章