List of usage examples for org.apache.commons.compress.bzip2 CBZip2InputStream close
public void close() throws IOException
From source file:ch.rgw.compress.CompEx.java
public static byte[] expand(InputStream in) { ByteArrayOutputStream baos;/*from www.ja va 2 s .c o m*/ byte[] siz = new byte[4]; try { in.read(siz); long size = BinConverter.byteArrayToInt(siz, 0); long typ = size & ~0x1fffffff; size &= 0x1fffffff; byte[] ret = new byte[(int) size]; switch ((int) typ) { case BZIP2: CBZip2InputStream bzi = new CBZip2InputStream(in); int off = 0; int l = 0; while ((l = bzi.read(ret, off, ret.length - off)) > 0) { off += l; } bzi.close(); in.close(); return ret; case GLZ: GLZ glz = new GLZ(); baos = new ByteArrayOutputStream(); glz.expand(in, baos); return baos.toByteArray(); case HUFF: HuffmanInputStream hin = new HuffmanInputStream(in); off = 0; l = 0; while ((l = hin.read(ret, off, ret.length - off)) > 0) { off += l; } hin.close(); return ret; case ZIP: ZipInputStream zi = new ZipInputStream(in); zi.getNextEntry(); off = 0; l = 0; while ((l = zi.read(ret, off, ret.length - off)) > 0) { off += l; } zi.close(); return ret; default: throw new Exception("Invalid compress format"); } } catch (Exception ex) { ExHandler.handle(ex); return null; } }