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 intMAGICStart 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 intdeflateToStream(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-InputStreamat 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-InputStreamat start of deflated bytes, i.e. after the stream header.inLen- number of deflated bytes in streaminoutLen- number of inflatedoutputbytes atoutOffoutput- sink for deflated bytesoutOff- offset tooutput- Returns:
- the inflated bytes from the stream, passing
outputfor chaining - Throws:
IOException- if an I/O or deflation exception occursArrayIndexOutOfBoundsException- ifoutOffandoutLenexceedsoutputIllegalArgumentException- 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 toinputinLen- number ofinputbytes atinOfflevel- compression level 0-9 orDeflater.DEFAULT_COMPRESSIONout- sink for deflated bytes- Returns:
- number of deflated bytes written, not including the header.
- Throws:
IOException- if an I/O or deflation exception occursArrayIndexOutOfBoundsException- ifinOffandinLenexceedsinputIllegalArgumentException- ifinLen≤ 0
-
-