Package com.vaadin.flow.internal
Class CompressUtil
java.lang.Object
com.vaadin.flow.internal.CompressUtil
Utility class for compression and decompression of folders, files and
strings.
For internal use only. May be renamed or removed in a future release.
- Since:
- 25.0
- Author:
- Vaadin Ltd
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidcompressDirectory(File targetDirectory, File outfile) Compress target directory and children into given target outfile.static byte[]deflateString(String text) Compresses a string with the deflate algorithm, favoring speed over size.static booleanhasFileInZip(File zip, String filename) Checks if the given zip file contains a file with the given name.static StringinflateString(byte[] data) Decompresses a string compressed withdeflateString(String).static StringreadFileContentFromZip(File zip, String filename) Read a file content from the given zip file.static voiduncompressFile(File zip, File targetDirectory) Uncompress given zip file content to the target directory.
-
Method Details
-
compressDirectory
Compress target directory and children into given target outfile. All files will be zipped and the targetDirectory will not be in the package.- Parameters:
targetDirectory- directory content to compressoutfile- file to compress directory content to
-
uncompressFile
Uncompress given zip file content to the target directory.- Parameters:
zip- file to uncompresstargetDirectory- target directory to uncompress files to
-
hasFileInZip
Checks if the given zip file contains a file with the given name.- Parameters:
zip- Target zip filefilename- Target file name- Returns:
trueif the file is found in the zip- Throws:
IOException- if an I/O error occurs- Since:
- 25.3
-
readFileContentFromZip
Read a file content from the given zip file.- Parameters:
zip- Target zip filefilename- Target file name- Returns:
- File content or
nullif not found - Throws:
IOException- if an I/O error occurs
-
deflateString
Compresses a string with the deflate algorithm, favoring speed over size. UseinflateString(byte[])to get the string back.- Parameters:
text- the string to compress, notnull- Returns:
- the compressed UTF-8 bytes of the string
-
inflateString
Decompresses a string compressed withdeflateString(String).- Parameters:
data- the compressed bytes, notnull- Returns:
- the original string
-