public class GZipCompression extends Object implements CompressionStrategy
GZipCompression
is a CompressionStrategy implementation using the
GZip library included in the JDK java.util.zip. This is the default
CompressionStrategy used by the CompressionHelper discovery when no other
implementation is discovered.Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_BUFFER_SIZE |
COMPRESSION_DEFAULT, SERVICE_ID
Constructor and Description |
---|
GZipCompression() |
Modifier and Type | Method and Description |
---|---|
byte[] |
compressByteArray(byte[] bytes)
Used for compressing a byte array into a new byte array using GZIP
|
InputStream |
compressInputStream(InputStream is)
Compresses an
InputStream . |
boolean |
isCompressed(byte[] bytes)
Determines if a byte array is compressed.
|
byte[] |
uncompressByteArray(byte[] bytes)
Used for uncompressing a byte array into a uncompressed byte array using GZIP
|
InputStream |
uncompressInputStream(InputStream is)
Uncompresses a compressed
InputStream . |
public static final int DEFAULT_BUFFER_SIZE
public boolean isCompressed(byte[] bytes) throws IOException
isCompressed
in interface CompressionStrategy
bytes
- an array of bytesIOException
- if the byte array couldn't be readpublic byte[] compressByteArray(byte[] bytes) throws IOException
compressByteArray
in interface CompressionStrategy
bytes
- An array of bytes to compressIOException
- if it fails to write to a GZIPOutputStreamGZIPOutputStream
public InputStream compressInputStream(InputStream is) throws IOException
CompressionStrategy
InputStream
.compressInputStream
in interface CompressionStrategy
is
- The InputStream
to compress.InputStream
.IOException
- If an I/O error has occurred.public byte[] uncompressByteArray(byte[] bytes) throws IOException
uncompressByteArray
in interface CompressionStrategy
bytes
- An array of bytes to uncompressIOException
- if it fails to read from a GZIPInputStreamGZIPInputStream
public InputStream uncompressInputStream(InputStream is) throws IOException
CompressionStrategy
InputStream
.uncompressInputStream
in interface CompressionStrategy
is
- The compressed InputStream
.InputStream
.IOException
- If an I/O error has occurred.Copyright © 2003–2016 MuleSoft, Inc.. All rights reserved.