io.github.nichetoolkit.rest.util.ZipUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rest-toolkit-utils Show documentation
Show all versions of rest-toolkit-utils Show documentation
Rest toolkit utils project for Spring Boot
The newest version!
package io.github.nichetoolkit.rest.util;
import io.github.nichetoolkit.rest.error.often.FileCreateException;
import io.github.nichetoolkit.rest.error.often.ZipErrorException;
import io.github.nichetoolkit.rest.helper.ZipHelper;
import lombok.extern.slf4j.Slf4j;
import java.io.File;
import java.util.List;
/**
* ZipUtils
* The zip utils class.
* @author Cyan ([email protected])
* @see lombok.extern.slf4j.Slf4j
* @see java.lang.SuppressWarnings
* @since Jdk1.8
*/
@Slf4j
@SuppressWarnings("SameNameButDifferent")
public class ZipUtils {
/**
* zipFile
* The zip file method.
* @param zipPath {@link java.lang.String} The zip path parameter is String
type.
* @param filename {@link java.lang.String} The filename parameter is String
type.
* @param file {@link java.io.File} The file parameter is File
type.
* @return {@link java.io.File} The zip file return object is File
type.
* @see java.lang.String
* @see java.io.File
*/
public static File zipFile(String zipPath, String filename, File file) {
try {
return ZipHelper.zipFile(zipPath,filename,file);
} catch (ZipErrorException | FileCreateException exception) {
log.error("It is failed during handle zip file with filename and file path! {}", exception.getMessage());
GeneralUtils.printStackTrace(exception);
}
return null;
}
/**
* zipFiles
* The zip files method.
* @param zipPath {@link java.lang.String} The zip path parameter is String
type.
* @param filename {@link java.lang.String} The filename parameter is String
type.
* @param zipFiles {@link java.util.List} The zip files parameter is List
type.
* @return {@link java.io.File} The zip files return object is File
type.
* @see java.lang.String
* @see java.util.List
* @see java.io.File
*/
public static File zipFiles(String zipPath, String filename, List zipFiles) {
try {
return ZipHelper.zipFiles(zipPath,filename,zipFiles);
} catch (ZipErrorException | FileCreateException exception) {
log.error("It is failed during handle zip files! {}", exception.getMessage());
GeneralUtils.printStackTrace(exception);
}
return null;
}
/**
* gzip
* The gzip method.
* @param bytes byte The bytes parameter is byte
type.
* @return byte The gzip return object is byte
type.
*/
public static byte[] gzip(byte[] bytes) {
try {
return ZipHelper.gzip(bytes);
} catch (ZipErrorException exception) {
log.error("It is failed during handle zip file with file bytes! {}", exception.getMessage());
GeneralUtils.printStackTrace(exception);
}
return new byte[0];
}
/**
* ungzip
* The ungzip method.
* @param bytes byte The bytes parameter is byte
type.
* @return byte The ungzip return object is byte
type.
*/
public static byte[] ungzip(byte[] bytes) {
try {
return ZipHelper.ungzip(bytes);
} catch (ZipErrorException exception) {
log.error("It is failed during handle unzip file with file bytes! {}", exception.getMessage());
GeneralUtils.printStackTrace(exception);
}
return new byte[0];
}
}