Instantly share code, notes, and snippets.

Embed
What would you like to do?
Inflating hex data (IDAT section from a PNG file)
import java.io.*;
import java.util.Arrays;
import java.util.zip.InflaterInputStream;
import javax.xml.bind.DatatypeConverter;
public class Inflate {
public static void main(String[] args) throws Exception {
String input = "6881EDC1010D000000C2A0F74F6D0E37A00000000000000000BE0D21000001";
byte[] deflated = DatatypeConverter.parseHexBinary(input);
ByteArrayInputStream bais = new ByteArrayInputStream(deflated);
InflaterInputStream iis = new InflaterInputStream(bais);
byte[] inflated = new byte[256*256];
int size = iis.read(inflated);
System.out.println(size);
System.out.println(DatatypeConverter.printHexBinary(Arrays.copyOf(inflated, size)));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment