Package adams.core.io
Class Bzip2Utils
- java.lang.Object
-
- adams.core.io.Bzip2Utils
-
public class Bzip2Utils extends Object
Helper class for bzip2 related operations.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
-
-
Constructor Summary
Constructors Constructor Description Bzip2Utils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static byte[]compress(byte[] input)Compresses the specified bytes using bzip2.static byte[]compress(byte[] input, MessageCollection errors)Compresses the specified bytes using bzip2.static Stringcompress(File inputFile, int buffer)Compresses the specified file to a file with the ".bz2" extension.static Stringcompress(File inputFile, int buffer, File outputFile)Compresses the specified file.static Stringcompress(File inputFile, int buffer, File outputFile, boolean removeInput)Compresses the specified file.static byte[]decompress(byte[] input, int buffer)Decompresses the specified bzip2 compressed bytes.static byte[]decompress(byte[] input, int buffer, MessageCollection errors)Decompresses the specified bzip2 compressed bytes.static Stringdecompress(File archiveFile, int buffer)Decompresses the specified archive to a file without the ".bz2" extension.static Stringdecompress(File archiveFile, int buffer, File outputFile)Decompresses the specified archive.static booleanisBzip2Compressed(byte[] data)Checks whether the array is bzip2 compressed.static booleanisBzip2Compressed(File file)Checks whether the file is bzip2 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 archive to a file without the ".bz2" extension.- Parameters:
archiveFile- the archive 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)
- Parameters:
archiveFile- the archive 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 file to a file with the ".bz2" extension.- Parameters:
inputFile- the 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 file. Does not remove the input file.- Parameters:
inputFile- the 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)
- Parameters:
inputFile- the 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 bzip2.- 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 bzip2.- 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 bzip2 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 bzip2 compressed bytes.- Parameters:
input- the compressed bytesbuffer- the buffer size to useerrors- for collecting errors- Returns:
- the decompressed bytes, null in case of error
-
isBzip2Compressed
public static boolean isBzip2Compressed(File file)
Checks whether the file is bzip2 compressed. See: https://en.wikipedia.org/wiki/Bzip2#File_format- Parameters:
file- the file to inspect- Returns:
- true if gzip
-
isBzip2Compressed
public static boolean isBzip2Compressed(byte[] data)
Checks whether the array is bzip2 compressed. See: https://en.wikipedia.org/wiki/Bzip2#File_format- Parameters:
data- the data to inspect- Returns:
- true if gzip
-
-