Answer the question
In order to leave comments, you need to log in
How to decompress gzip android?
Hello.
For the project, I need to unpack the string packed by the php function
<?php
echo base64_encode(aes(gzdeflate("123456")));
Answer the question
In order to leave comments, you need to log in
android code
public static byte[] decompress(byte[] data) throws IOException, DataFormatException {
Inflater inflater = new Inflater(true);
inflater.setInput(data);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream(data.length);
byte[] buffer = new byte[1024];
while (!inflater.finished()) {
int count = inflater.inflate(buffer);
outputStream.write(buffer, 0, count);
}
outputStream.close();
byte[] output = outputStream.toByteArray();
// LOG.debug("Original: " + data.length);
// LOG.debug("Compressed: " + output.length);
return output;
}
09-04 15:39:59.930 10602-10683/ru.cabi W/System.err: java.util.zip.DataFormatException: invalid stored block lengths
09-04 15:39:59.930 10602-10683/ru.cabi W/System.err: at java.util.zip.Inflater.inflateImpl(Native Method)
09-04 15:39:59.930 10602-10683/ru.cabi W/System.err: at java.util.zip.Inflater.inflate(Inflater.java:237)
09-04 15:39:59.930 10602-10683/ru.cabi W/System.err: at java.util.zip.Inflater.inflate(Inflater.java:214)
09-04 15:39:59.930 10602-10683/ru.cabi W/System.err: at ru.cabi.Help.decompress(Help.java:450)
09-04 15:39:59.930 10602-10683/ru.cabi W/System.err: at ru.cabi.Help.getData(Help.java:420)
09-04 15:39:59.930 10602-10683/ru.cabi W/System.err: at ru.cabi.UpdateProc.updateTimetable(UpdateProc.java:95)
09-04 15:39:59.930 10602-10683/ru.cabi W/System.err: at ru.cabi.SelectGActivity$TaskUpdate.doInBackground(SelectGActivity.java:402)
09-04 15:39:59.930 10602-10683/ru.cabi W/System.err: at ru.cabi.SelectGActivity$TaskUpdate.doInBackground(SelectGActivity.java:391)
09-04 15:39:59.930 10602-10683/ru.cabi W/System.err: at android.os.AsyncTask$2.call(AsyncTask.java:295)
09-04 15:39:59.930 10602-10683/ru.cabi W/System.err: at java.util.concurrent.FutureTask.run(FutureTask.java:237)
09-04 15:39:59.930 10602-10683/ru.cabi W/System.err: at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)
09-04 15:39:59.930 10602-10683/ru.cabi W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
09-04 15:39:59.930 10602-10683/ru.cabi W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
09-04 15:39:59.930 10602-10683/ru.cabi W/System.err: at java.lang.Thread.run(Thread.java:818)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question