public class ZipPackager extends Object
Constructor and Description |
---|
ZipPackager() |
Modifier and Type | Method and Description |
---|---|
ZipPackager |
addBytes(String key,
byte[] bytes)
Key as zip entry name.
|
ZipPackager |
addPath(Path path)
If the path to file is null or not exists, the method does nothing.
|
ZipPackager |
addPaths(Path baseDir,
List<String> filenames) |
ZipPackager |
addPaths(Path root,
String... filenames) |
ZipPackager |
addString(String key,
String content)
Key as zip entry name.
|
ZipPackager |
addString(String key,
String content,
Charset charset)
Key as zip entry name.
|
static byte[] |
archiveBytesByNameToZipBytes(Map<String,byte[]> bytesByName)
Generates a zip file's bytes
|
static byte[] |
archiveFilesToZipBytes(Path baseDir,
List<String> fileNames)
If the file is in .gz(detected by last 3 characters) format, the method decompresses .gz file first.
|
static byte[] |
archiveFilesToZipBytes(Path workingDir,
String... fileNames) |
byte[] |
toZipBytes()
Should only be called once.
|
public ZipPackager addPath(@Nullable Path path)
path
- the file to add in zip bytespublic ZipPackager addPaths(Path baseDir, List<String> filenames)
baseDir
- the base directory of all filesfilenames
- all files to add in zip bytespublic ZipPackager addPaths(Path root, String... filenames)
baseDir
- the base directory of all filesfilenames
- all files to add in zip bytespublic ZipPackager addString(String key, String content)
key
- content
- public ZipPackager addString(String key, String content, Charset charset)
key
- content
- charset
- be used to encode contentpublic ZipPackager addBytes(String key, byte[] bytes)
key
- bytes
- public byte[] toZipBytes()
public static byte[] archiveFilesToZipBytes(Path baseDir, List<String> fileNames)
baseDir
- the base directory contaions files to zipfileNames
- the files to be added in zippublic static byte[] archiveFilesToZipBytes(Path workingDir, String... fileNames)
Copyright © 2020. All rights reserved.