Package com.jogamp.common.util
Class CustomCompress
- java.lang.Object
-
- com.jogamp.common.util.CustomCompress
-
public class CustomCompress extends Object
All in memory inflater / deflator for small chunks using streamsStream header of deflated data:
- 4 bytes magic 0xDEF1A7E0 (Big Endian)
- 4 bytes integer deflated-size (Big Endian)
- 4 bytes integer inflated-size (Big Endian)
- deflated bytes
-
-
Field Summary
Fields Modifier and Type Field Description static int
MAGIC
Start of stream header for deflated data
-
Constructor Summary
Constructors Constructor Description CustomCompress()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static int
deflateToStream(byte[] input, int inOff, int inLen, int level, OutputStream out)
static byte[]
inflateFromStream(InputStream in)
static byte[]
inflateFromStream(InputStream in, int inLen, int outLen, byte[] output, int outOff)
-
-
-
Field Detail
-
MAGIC
public static final int MAGIC
Start of stream header for deflated data- See Also:
- Constant Field Values
-
-
Method Detail
-
inflateFromStream
public static byte[] inflateFromStream(InputStream in) throws IOException, ArrayIndexOutOfBoundsException, IllegalArgumentException
- Parameters:
in
-InputStream
at start of stream header, i.e. positionMAGIC
.- Returns:
- the inflated bytes from the stream
- Throws:
IOException
- if an I/O or deflation exception occursIllegalArgumentException
- ifinLen
≤ 0 oroutLen
≤ 0, as read from headerArrayIndexOutOfBoundsException
-
inflateFromStream
public static byte[] inflateFromStream(InputStream in, int inLen, int outLen, byte[] output, int outOff) throws IOException, ArrayIndexOutOfBoundsException, IllegalArgumentException
- Parameters:
in
-InputStream
at start of deflated bytes, i.e. after the stream header.inLen
- number of deflated bytes in streamin
outLen
- number of inflatedoutput
bytes atoutOff
output
- sink for deflated bytesoutOff
- offset tooutput
- Returns:
- the inflated bytes from the stream, passing
output
for chaining - Throws:
IOException
- if an I/O or deflation exception occursArrayIndexOutOfBoundsException
- ifoutOff
andoutLen
exceedsoutput
IllegalArgumentException
- ifinLen
≤ 0 oroutLen
≤ 0
-
deflateToStream
public static int deflateToStream(byte[] input, int inOff, int inLen, int level, OutputStream out) throws IOException, ArrayIndexOutOfBoundsException, IllegalArgumentException
- Parameters:
input
- raw input bytesinOff
- offset toinput
inLen
- number ofinput
bytes atinOff
level
- compression level 0-9 orDeflater.DEFAULT_COMPRESSION
out
- sink for deflated bytes- Returns:
- number of deflated bytes written, not including the header.
- Throws:
IOException
- if an I/O or deflation exception occursArrayIndexOutOfBoundsException
- ifinOff
andinLen
exceedsinput
IllegalArgumentException
- ifinLen
≤ 0
-
-