Package adams.core.io
Class GzipUtils
- java.lang.Object
-
- adams.core.io.GzipUtils
-
public class GzipUtils extends Object
Helper class for gzip related operations.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
-
-
Constructor Summary
Constructors Constructor Description GzipUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static byte[]
compress(byte[] input)
Compresses the specified bytes using gzip.static byte[]
compress(byte[] input, MessageCollection errors)
Compresses the specified bytes using gzip.static String
compress(File inputFile, int buffer)
Compresses the specified gzip archive to a file with the ".gz" extension.static String
compress(File inputFile, int buffer, File outputFile)
Compresses the specified gzip archive.static String
compress(File inputFile, int buffer, File outputFile, boolean removeInput)
Compresses the specified gzip archive.static byte[]
decompress(byte[] input, int buffer)
Decompresses the specified gzip compressed bytes.static byte[]
decompress(byte[] input, int buffer, MessageCollection errors)
Decompresses the specified gzip compressed bytes.static String
decompress(File archiveFile, int buffer)
Decompresses the specified gzip archive to a file without the ".gz" extension.static String
decompress(File archiveFile, int buffer, File outputFile)
Decompresses the specified gzip archive.static boolean
isGzipCompressed(byte[] data)
Checks whether the array is gzip compressed.static boolean
isGzipCompressed(File file)
Checks whether the file is gzip compressed.
-
-
-
Field Detail
-
EXTENSION
public static final String EXTENSION
the default extension.- See Also:
- Constant Field Values
-
LOGGER
protected static Logger LOGGER
for logging errors.
-
-
Method Detail
-
decompress
public static String decompress(File archiveFile, int buffer)
Decompresses the specified gzip archive to a file without the ".gz" extension.- Parameters:
archiveFile
- the gzip file to decompressbuffer
- the buffer size to use- Returns:
- the error message, null if everything OK
-
decompress
public static String decompress(File archiveFile, int buffer, File outputFile)
Decompresses the specified gzip archive.- Parameters:
archiveFile
- the gzip file to decompressbuffer
- the buffer size to useoutputFile
- the destination file- Returns:
- the error message, null if everything OK
-
compress
public static String compress(File inputFile, int buffer)
Compresses the specified gzip archive to a file with the ".gz" extension.- Parameters:
inputFile
- the gzip file to compressbuffer
- the buffer size to use- Returns:
- the error message, null if everything OK
-
compress
public static String compress(File inputFile, int buffer, File outputFile)
Compresses the specified gzip archive. Does not remove the input file.- Parameters:
inputFile
- the gzip file to compressbuffer
- the buffer size to useoutputFile
- the destination file (the archive)- Returns:
- the error message, null if everything OK
-
compress
public static String compress(File inputFile, int buffer, File outputFile, boolean removeInput)
Compresses the specified gzip archive.- Parameters:
inputFile
- the gzip file to compressbuffer
- the buffer size to useoutputFile
- the destination file (the archive)removeInput
- whether to remove the input file- Returns:
- the error message, null if everything OK
-
compress
public static byte[] compress(byte[] input)
Compresses the specified bytes using gzip.- Parameters:
input
- the bytes to compress- Returns:
- the compressed bytes, null in case of error
-
compress
public static byte[] compress(byte[] input, MessageCollection errors)
Compresses the specified bytes using gzip.- Parameters:
input
- the bytes to compress- Returns:
- the compressed bytes, null in case of error
-
decompress
public static byte[] decompress(byte[] input, int buffer)
Decompresses the specified gzip compressed bytes.- Parameters:
input
- the compressed bytesbuffer
- the buffer size to use- Returns:
- the decompressed bytes, null in case of error
-
decompress
public static byte[] decompress(byte[] input, int buffer, MessageCollection errors)
Decompresses the specified gzip compressed bytes.- Parameters:
input
- the compressed bytesbuffer
- the buffer size to useerrors
- for collecting errors- Returns:
- the decompressed bytes, null in case of error
-
isGzipCompressed
public static boolean isGzipCompressed(File file)
Checks whether the file is gzip compressed. See: https://en.wikipedia.org/wiki/Gzip#File_format- Parameters:
file
- the file to inspect- Returns:
- true if gzip
-
isGzipCompressed
public static boolean isGzipCompressed(byte[] data)
Checks whether the array is gzip compressed. See: https://en.wikipedia.org/wiki/Gzip#File_format- Parameters:
data
- the data to inspect- Returns:
- true if gzip
-
-