@Override protected InputStream wrapObjectStream(URI object, InputStream stream) throws IOException { return object.getPath().endsWith(".gz") ? CompressionUtils.gzipInputStream(stream) : stream; }
@Override protected InputStream wrapObjectStream(File object, InputStream stream) throws IOException { return object.getPath().endsWith(".gz") ? CompressionUtils.gzipInputStream(stream) : stream; } }
@Override public InputStream openStream() throws IOException { return gzipInputStream(in.openStream()); } },
@Override protected InputStream wrapObjectStream(S3Object object, InputStream stream) throws IOException { return object.getKey().endsWith(".gz") ? CompressionUtils.gzipInputStream(stream) : stream; }
/** * gunzip from the source stream to the destination stream. * * @param in The input stream which is to be decompressed. This stream is closed. * @param out The output stream to write to. This stream is closed * * @return The number of bytes written to the output stream. * * @throws IOException */ public static long gunzip(InputStream in, OutputStream out) throws IOException { try (GZIPInputStream gzipInputStream = gzipInputStream(in)) { final long result = ByteStreams.copy(gzipInputStream, out); out.flush(); return result; } finally { out.close(); } }
/** * Unzips the input stream via a gzip filter. use gunzip(ByteSource, File, Predicate) if possible * * @param in The input stream to run through the gunzip filter. This stream is closed * @param outFile The file to output to * * @throws IOException */ public static FileUtils.FileCopyResult gunzip(InputStream in, File outFile) throws IOException { try (GZIPInputStream gzipInputStream = gzipInputStream(in)) { Files.asByteSink(outFile).writeFrom(gzipInputStream); return new FileUtils.FileCopyResult(outFile); } }