diff options
Diffstat (limited to 'src/com/isode/stroke/compress/ZLibDecompressor.java')
-rw-r--r-- | src/com/isode/stroke/compress/ZLibDecompressor.java | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/com/isode/stroke/compress/ZLibDecompressor.java b/src/com/isode/stroke/compress/ZLibDecompressor.java new file mode 100644 index 0000000..2c78a57 --- /dev/null +++ b/src/com/isode/stroke/compress/ZLibDecompressor.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2011, Isode Limited, London, England. + * All rights reserved. + */ +package com.isode.stroke.compress; + +import com.isode.stroke.base.ByteArray; +import java.util.zip.DataFormatException; +import java.util.zip.Inflater; + +/** + * + * @author Kev + */ +public class ZLibDecompressor { + Inflater inflater_ = new Inflater(); + public ByteArray process(ByteArray data) throws ZLibException { + try { + inflater_.setInput(data.getData()); + byte[] output = new byte[100]; + ByteArray result = new ByteArray(); + int size = 0; + while ((size = inflater_.inflate(output)) != 0) { + for (int i = 0; i < size; i++) { + result.append(output[i]); /* TODO: Terribly slow */ + } + } + return result; + } + catch (DataFormatException e) { + throw new ZLibException(); + } + } + +} |