Package com.jogamp.common.util
Class CustomCompress
java.lang.Object
com.jogamp.common.util.CustomCompress
All in memory inflater / deflator for small chunks using streams
Stream 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 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intdeflateToStream(byte[] input, int inOff, int inLen, int level, OutputStream out) static byte[]static byte[]inflateFromStream(InputStream in, int inLen, int outLen, byte[] output, int outOff)
-
Field Details
-
MAGIC
public static final int MAGICStart of stream header for deflated data- See Also:
-
-
Constructor Details
-
CustomCompress
public CustomCompress()
-
-
Method Details
-
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
-