gpt4 book ai didi

com.blankj.util.ZipUtils类的使用及代码示例

转载 作者:知者 更新时间:2024-03-13 12:26:08 28 4
gpt4 key购买 nike

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

ZipUtils介绍

[英]```
author: Blankj
blog : http://blankj.com
time : 2016/08/27
desc : utils about zip or jar

[中]```
author: Blankj 
blog  : http://blankj.com 
time  : 2016/08/27 
desc  : utils about zip or jar

代码示例

代码示例来源:origin: Blankj/AndroidUtilCode

files.add(file);
if (entry.isDirectory()) {
  return createOrExistsDir(file);
} else {
  if (!createOrExistsFile(file)) return false;
  InputStream in = null;
  OutputStream out = null;

代码示例来源:origin: Blankj/AndroidUtilCode

/**
 * Return the files' comment in ZIP file.
 *
 * @param zipFilePath The path of ZIP file.
 * @return the files' comment in ZIP file
 * @throws IOException if an I/O error has occurred
 */
public static List<String> getComments(final String zipFilePath)
    throws IOException {
  return getComments(getFileByPath(zipFilePath));
}

代码示例来源:origin: Blankj/AndroidUtilCode

/**
 * Return the files' path in ZIP file.
 *
 * @param zipFilePath The path of ZIP file.
 * @return the files' path in ZIP file
 * @throws IOException if an I/O error has occurred
 */
public static List<String> getFilesPath(final String zipFilePath)
    throws IOException {
  return getFilesPath(getFileByPath(zipFilePath));
}

代码示例来源:origin: Blankj/AndroidUtilCode

/**
 * Zip the file.
 *
 * @param srcFilePath The path of source file.
 * @param zipFilePath The path of ZIP file.
 * @return {@code true}: success<br>{@code false}: fail
 * @throws IOException if an I/O error has occurred
 */
public static boolean zipFile(final String srcFilePath,
               final String zipFilePath)
    throws IOException {
  return zipFile(getFileByPath(srcFilePath), getFileByPath(zipFilePath), null);
}

代码示例来源:origin: Blankj/AndroidUtilCode

/**
 * Unzip the file by keyword.
 *
 * @param zipFilePath The path of ZIP file.
 * @param destDirPath The path of destination directory.
 * @param keyword     The keyboard.
 * @return the unzipped files
 * @throws IOException if unzip unsuccessfully
 */
public static List<File> unzipFileByKeyword(final String zipFilePath,
                      final String destDirPath,
                      final String keyword)
    throws IOException {
  return unzipFileByKeyword(getFileByPath(zipFilePath), getFileByPath(destDirPath), keyword);
}

代码示例来源:origin: Blankj/AndroidUtilCode

final String comment)
  throws IOException {
rootPath = rootPath + (isSpace(rootPath) ? "" : File.separator) + srcFile.getName();
if (srcFile.isDirectory()) {
  File[] fileList = srcFile.listFiles();
  } else {
    for (File file : fileList) {
      if (!zipFile(file, rootPath, zos, comment)) return false;

代码示例来源:origin: Blankj/AndroidUtilCode

Enumeration<?> entries = zip.entries();
try {
  if (isSpace(keyword)) {
    while (entries.hasMoreElements()) {
      ZipEntry entry = ((ZipEntry) entries.nextElement());
        continue;
      if (!unzipChildFile(destDir, files, zip, entry, entryName)) return files;
        if (!unzipChildFile(destDir, files, zip, entry, entryName)) return files;

代码示例来源:origin: Blankj/AndroidUtilCode

/**
 * Zip the file.
 *
 * @param srcFile The source of file.
 * @param zipFile The ZIP file.
 * @return {@code true}: success<br>{@code false}: fail
 * @throws IOException if an I/O error has occurred
 */
public static boolean zipFile(final File srcFile,
               final File zipFile)
    throws IOException {
  return zipFile(srcFile, zipFile, null);
}

代码示例来源:origin: Blankj/AndroidUtilCode

/**
 * Zip the files.
 *
 * @param srcFiles The source of files.
 * @param zipFile  The ZIP file.
 * @return {@code true}: success<br>{@code false}: fail
 * @throws IOException if an I/O error has occurred
 */
public static boolean zipFiles(final Collection<File> srcFiles, final File zipFile)
    throws IOException {
  return zipFiles(srcFiles, zipFile, null);
}

代码示例来源:origin: Blankj/AndroidUtilCode

/**
 * Unzip the file.
 *
 * @param zipFile The ZIP file.
 * @param destDir The destination directory.
 * @return the unzipped files
 * @throws IOException if unzip unsuccessfully
 */
public static List<File> unzipFile(final File zipFile,
                  final File destDir)
    throws IOException {
  return unzipFileByKeyword(zipFile, destDir, null);
}

代码示例来源:origin: Blankj/AndroidUtilCode

private static boolean createOrExistsFile(final File file) {
  if (file == null) return false;
  if (file.exists()) return file.isFile();
  if (!createOrExistsDir(file.getParentFile())) return false;
  try {
    return file.createNewFile();
  } catch (IOException e) {
    e.printStackTrace();
    return false;
  }
}

代码示例来源:origin: Blankj/AndroidUtilCode

private static File getFileByPath(final String filePath) {
  return isSpace(filePath) ? null : new File(filePath);
}

代码示例来源:origin: Blankj/AndroidUtilCode

/**
 * Zip the file.
 *
 * @param srcFilePath The path of source file.
 * @param zipFilePath The path of ZIP file.
 * @param comment     The comment.
 * @return {@code true}: success<br>{@code false}: fail
 * @throws IOException if an I/O error has occurred
 */
public static boolean zipFile(final String srcFilePath,
               final String zipFilePath,
               final String comment)
    throws IOException {
  return zipFile(getFileByPath(srcFilePath), getFileByPath(zipFilePath), comment);
}

代码示例来源:origin: gradle.plugin.com.blankj/bus-gradle-plugin

/**
 * Unzip the file by keyword.
 *
 * @param zipFilePath The path of ZIP file.
 * @param destDirPath The path of destination directory.
 * @param keyword     The keyboard.
 * @return the unzipped files
 * @throws IOException if unzip unsuccessfully
 */
public static List<File> unzipFileByKeyword(final String zipFilePath,
                      final String destDirPath,
                      final String keyword)
    throws IOException {
  return unzipFileByKeyword(getFileByPath(zipFilePath), getFileByPath(destDirPath), keyword);
}

代码示例来源:origin: gradle.plugin.com.blankj/bus-gradle-plugin

final String comment)
  throws IOException {
rootPath = rootPath + (isSpace(rootPath) ? "" : File.separator) + srcFile.getName();
if (srcFile.isDirectory()) {
  File[] fileList = srcFile.listFiles();
  } else {
    for (File file : fileList) {
      if (!zipFile(file, rootPath, zos, comment)) return false;

代码示例来源:origin: gradle.plugin.com.blankj/bus-gradle-plugin

Enumeration<?> entries = zip.entries();
try {
  if (isSpace(keyword)) {
    while (entries.hasMoreElements()) {
      ZipEntry entry = ((ZipEntry) entries.nextElement());
      if (!unzipChildFile(destDir, files, zip, entry)) return files;
      ZipEntry entry = ((ZipEntry) entries.nextElement());
      if (entry.getName().contains(keyword)) {
        if (!unzipChildFile(destDir, files, zip, entry)) return files;

代码示例来源:origin: Blankj/AndroidUtilCode

/**
 * Zip the file.
 *
 * @param srcFile The source of file.
 * @param zipFile The ZIP file.
 * @param comment The comment.
 * @return {@code true}: success<br>{@code false}: fail
 * @throws IOException if an I/O error has occurred
 */
public static boolean zipFile(final File srcFile,
               final File zipFile,
               final String comment)
    throws IOException {
  if (srcFile == null || zipFile == null) return false;
  ZipOutputStream zos = null;
  try {
    zos = new ZipOutputStream(new FileOutputStream(zipFile));
    return zipFile(srcFile, "", zos, comment);
  } finally {
    if (zos != null) {
      zos.close();
    }
  }
}

代码示例来源:origin: Blankj/AndroidUtilCode

/**
 * Zip the files.
 *
 * @param srcFiles    The source of files.
 * @param zipFilePath The path of ZIP file.
 * @return {@code true}: success<br>{@code false}: fail
 * @throws IOException if an I/O error has occurred
 */
public static boolean zipFiles(final Collection<String> srcFiles,
                final String zipFilePath)
    throws IOException {
  return zipFiles(srcFiles, zipFilePath, null);
}

代码示例来源:origin: Blankj/AndroidUtilCode

/**
 * Unzip the file.
 *
 * @param zipFilePath The path of ZIP file.
 * @param destDirPath The path of destination directory.
 * @return the unzipped files
 * @throws IOException if unzip unsuccessfully
 */
public static List<File> unzipFile(final String zipFilePath,
                  final String destDirPath)
    throws IOException {
  return unzipFileByKeyword(zipFilePath, destDirPath, null);
}

代码示例来源:origin: gradle.plugin.com.blankj/bus-gradle-plugin

private static boolean createOrExistsFile(final File file) {
  if (file == null) return false;
  if (file.exists()) return file.isFile();
  if (!createOrExistsDir(file.getParentFile())) return false;
  try {
    return file.createNewFile();
  } catch (IOException e) {
    e.printStackTrace();
    return false;
  }
}

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