public static byte[] gunzip(byte[] data) { try { ByteArrayOutputStream bos = new ByteArrayOutputStream(); ByteArrayInputStream bis = new ByteArrayInputStream(data); GZIPInputStream in = new GZIPInputStream(bis); byte[] buffer = new byte[1024]; int len = 0; while ((len = in.read(buffer)) >= 0) { bos.write(buffer, 0, len); } in.close(); bos.close(); return bos.toByteArray(); } catch (IOException e) { throw new RuntimeException(e); } }
@Override public Void call() throws IOException { GZIPInputStream in = new GZIPInputStream(mIn); try { Util.copy(in, mOut, new byte[1024]); } finally { in.close(); mOut.close(); } return null; } }
private static boolean isGZIP(File headDump) { try { FileInputStream in = new FileInputStream(headDump); GZIPInputStream is; try { is = new GZIPInputStream(in); is.read(); is.close(); return true; } catch (IOException e) { in.close(); } } catch (IOException e) { // ignore } return false; }
public static byte[] unZip(byte[] data) throws IOException { ByteArrayInputStream in = new ByteArrayInputStream(data); java.util.zip.GZIPInputStream gin = new GZIPInputStream(in); data = FileUtil.readAll(gin); gin.close(); return data; } }
public static ByteBuffer doDecompress(ByteBuffer buffer, int length) { byte[] byteArrayIn = new byte[1024]; ByteArrayInputStream byteIn; if (buffer.hasArray()) { byteIn = new ByteArrayInputStream(buffer.array(), buffer.position() + buffer.arrayOffset(), buffer.remaining()); } else { byte[] array = new byte[buffer.limit() - buffer.position()]; buffer.get(array); byteIn = new ByteArrayInputStream(array); } ByteBuffer retBuff = ByteBuffer.allocate(length); int len = 0; try { GZIPInputStream in = new GZIPInputStream(byteIn); while ((len = in.read(byteArrayIn)) > 0) { retBuff.put(byteArrayIn, 0, len); } in.close(); } catch (IOException e) { s_logger.error("Fail to decompress the request!", e); } retBuff.flip(); return retBuff; }
public static byte[] unGzip(byte[] data) throws IOException { GZIPInputStream gzip = null; try { gzip = new GZIPInputStream(new ByteArrayInputStream(data)); byte[] buf = new byte[2048]; int size = -1; ByteArrayOutputStream bos = new ByteArrayOutputStream(data.length + 1024); while ((size = gzip.read(buf, 0, buf.length)) != -1) { bos.write(buf, 0, size); } return bos.toByteArray(); } finally { if (gzip != null) { gzip.close(); } } } }
public static byte[] unZip(byte[] data) throws IOException { ByteArrayInputStream in = new ByteArrayInputStream(data); java.util.zip.GZIPInputStream gin = new GZIPInputStream(in); data = FileUtil.readAll(gin); gin.close(); return data; } }
public static void gunzip(File source, File dest, boolean deleteSource) throws IOException { byte[] buffer = new byte[2^20]; FileOutputStream out = new FileOutputStream(dest); GZIPInputStream in = new GZIPInputStream(new BufferedInputStream(new FileInputStream(source))); int l; while ((l = in.read(buffer)) > 0) out.write(buffer, 0, l); in.close(); out.close(); if (deleteSource && dest.exists()) source.delete(); }
ObjectMetadata objMet = obj.getObjectMetadata(); FileOutputStream fos = new FileOutputStream(cachedFile); GZIPInputStream gis = new GZIPInputStream(obj.getObjectContent()); try { ByteStreams.copy(gis, fos); } finally { fos.close(); gis.close();
public static byte[] readCompressedByteArray(DataInput in) throws IOException { int length = in.readInt(); if (length == -1) { return null; } byte[] buffer = new byte[length]; in.readFully(buffer); // could/should use readFully(buffer,0,length)? GZIPInputStream gzi = new GZIPInputStream(new ByteArrayInputStream(buffer, 0, buffer.length)); byte[] outbuf = new byte[length]; ByteArrayOutputStream bos = new ByteArrayOutputStream(); int len; while ((len = gzi.read(outbuf, 0, outbuf.length)) != -1) { bos.write(outbuf, 0, len); } byte[] decompressed = bos.toByteArray(); bos.close(); gzi.close(); return decompressed; }
public static byte[] unZip(byte[] data) throws IOException { ByteArrayInputStream in = new ByteArrayInputStream(data); java.util.zip.GZIPInputStream gin = new GZIPInputStream(in); data = FileUtil.readAll(gin); gin.close(); return data; } }
private static void extractGzip(String filePath, String outputPath) throws IOException { System.out.println("Extracting files..."); byte[] buffer = new byte[BUFFER_SIZE]; try{ GZIPInputStream gzis = new GZIPInputStream(new FileInputStream(new File(filePath))); FileOutputStream out = new FileOutputStream(new File(outputPath)); int len; while ((len = gzis.read(buffer)) > 0) { out.write(buffer, 0, len); } gzis.close(); out.close(); System.out.println("Done"); }catch(IOException ex){ ex.printStackTrace(); } }
final GZIPInputStream in = new GZIPInputStream(new FileInputStream(inputFile)); final FileOutputStream out = new FileOutputStream(outputFile); in.close(); out.close();
public static byte[] gunzip(byte[] data) { try { ByteArrayOutputStream bos = new ByteArrayOutputStream(); ByteArrayInputStream bis = new ByteArrayInputStream(data); GZIPInputStream in = new GZIPInputStream(bis); byte[] buffer = new byte[1024]; int len; while ((len = in.read(buffer)) >= 0) { bos.write(buffer, 0, len); } in.close(); bos.close(); return bos.toByteArray(); } catch (IOException e) { throw new RuntimeException(e); } }
public static byte[] unZip(byte[] data) throws IOException { ByteArrayInputStream in = new ByteArrayInputStream(data); java.util.zip.GZIPInputStream gin = new GZIPInputStream(in); data = FileUtil.readAll(gin); gin.close(); return data; } }
public static File decodeGZipFile(File file) throws Throwable { GZIPInputStream gzipIn = null; FileOutputStream gzipOut = null; try { gzipIn = new GZIPInputStream(new FileInputStream(file)); file = new File(file.getAbsolutePath() + ".gziptemp"); gzipOut = new FileOutputStream(file); byte[] buf = new byte[1024 * 8]; int num = -1; while ((num = gzipIn.read(buf, 0, buf.length)) != -1) { gzipOut.write(buf, 0, num); } } finally { if (gzipIn != null) gzipIn.close(); if (gzipOut != null) gzipOut.close(); } return file; }
data.fis.add( fi ); if ( data.compressFiles ) { di = getDataInputStream( new GZIPInputStream( new BufferedInputStream( fi ) ) ); } else { di = new DataInputStream( new BufferedInputStream( fi, 50000 ) ); fi.close(); if ( gzfi != null ) { gzfi.close();
public static byte[] gunzip(byte[] b) { byte[] buffer = new byte[Math.min(2^20, b.length)]; try { ByteArrayOutputStream baos = new ByteArrayOutputStream(b.length * 2); GZIPInputStream in = new GZIPInputStream(new ByteArrayInputStream(b), Math.min(65536, b.length)); int l; while ((l = in.read(buffer)) > 0) baos.write(buffer, 0, l); in.close(); baos.close(); return baos.toByteArray(); } catch (IOException e) {} return null; }
public static byte[] unZip(byte[] data) throws IOException { ByteArrayInputStream in = new ByteArrayInputStream(data); java.util.zip.GZIPInputStream gin = new GZIPInputStream(in); data = FileUtil.readAll(gin); gin.close(); return data; } }
in = new GZIPInputStream(new FileInputStream(inFileName)); } catch (FileNotFoundException e) { System.err.println("File not found. " + inFileName); byte[] buf = new byte[1024]; int len; while ((len = in.read(buf)) > 0) { out.write(buf, 0, len); } finally { try { if (in != null) in.close(); if (out != null) out.close(); } catch (IOException e) {