1package com.osroyale.fs.util;
3import com.osroyale.fs.cache.FileSystem;
4import org.apache.tools.bzip2.CBZip2InputStream;
6import java.io.ByteArrayInputStream;
7import java.io.IOException;
8import java.util.zip.GZIPInputStream;
10import static com.google.common.io.ByteStreams.toByteArray;
40* A
static-utility
class containing containing extension or helper methods for
41 * <b>co</b>mpressor-<b>dec</b>compressor<b>
's</b>.
42 * @author Ryley Kimmel <ryley.kimmel@live.com>
44public final class CompressionUtil {
52 public static byte[] gunzip(byte[] data) throws IOException {
53 return toByteArray(new GZIPInputStream(new ByteArrayInputStream(data)));
71 public static byte[] unbzip2Headerless(byte[] data, int offset, int length) throws IOException {
72 /* Strip the header from the data. */
73 byte[] bzip2 = new byte[length + 2];
76 System.arraycopy(data, offset, bzip2, 2, length);
78 /* Uncompress the headerless data */
79 return unbzip2(bzip2);
88 public static byte[] unbzip2(byte[] data) throws IOException {
89 return toByteArray(new CBZip2InputStream(new ByteArrayInputStream(data)));
98 private CompressionUtil() {
99 throw new UnsupportedOperationException("static-utility classes may not be instantiated.");